I'm having problems using the FileUpload control in asp.NET. For some reason, when I try to upload a file, the file becomes empty. I can save the file without any problems - and when I check the contents of the POST that is sent to the page, the data is sent (I used firebug to look at the headers to see if something crazy is happening), but the control just saves an empty file and claims that the file size is -2 in the code below.
Does anyone know what could be here?
try { UploadFile.PostedFile.SaveAs(filename); } catch (Exception ex) { lblStatus.Text = "NOT OK - COULDN'T SAVE:" + filename + " " + ex.ToString(); throw; } lblStatus.Text = "File Size: " + UploadFile.PostedFile.ContentLength.ToString();
Please note that for some reason UploadFile.HasFile returns false and get the same results if I try to upload UploadFile.SaveAs (filename) or UploadFile.PostedFile.SaveAs (file name).
Any help that can be provided will be appreciated.
source share