Take the 2-minute tour ×

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);

share|improve this question

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!

share|improve this answer

Your Answer


