Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

When I click on upload button it says that my fileupload does not contain a file. Why that? Did I miss something in my code?

                //Add profilepic to SP list
                SPList myProfileDocList = web.Lists.TryGetList("Employee documents");

                SPListItem profileDocListItem = myProfileDocList.Items.Add();
                profileDocListItem["Title"] = strUserName;

                if (FileUploadEmployeeDoc.PostedFile != null && FileUploadEmployeeDoc.HasFile)
                {
                    Stream fStream = FileUploadEmployeeDoc.PostedFile.InputStream;
                    var profPicContents = new byte[fStream.Length];
                    fStream.Read(profPicContents, 0, (int)fStream.Length);
                    fStream.Close();
                    fStream.Dispose();
                    SPAttachmentCollection profileDocAttachment = profileDocListItem.Attachments;
                    string profPicFileName = Path.GetFileName(FileUploadEmployeeDoc.FileName);

                    profileDocAttachment.Add(profPicFileName, profPicContents);
                }

                profileDocListItem.Update();
share|improve this question
add comment

1 Answer

Sir, it would be great if you could provide some more information about the problem. What are you trying to do? In which context? Thanks!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.