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