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);
                    SPAttachmentCollection profileDocAttachment = profileDocListItem.Attachments;
                    string profPicFileName = Path.GetFileName(FileUploadEmployeeDoc.FileName);

                    profileDocAttachment.Add(profPicFileName, profPicContents);


1 Answer 1


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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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