Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileUpload control won't accept 0kb file?

I was using blank text files to run some tests, and was going crazy because FileUpload1.HasFile was always coming back false, even though it clearly had a file. I then switched test files to something above 0 kb (i.e. txt files with text in them), and then it worked.

As far as I can tell, you can't upload something of 0 kb. Is this true? I read about the FileUpload class on MSDN, but didn't notice anything that says files of 0 kb would be ignored/treated as not a file.

Realistically and practically, I don't see this as being much of a problem (why would you want to upload a blank file?), but I can imagine some kind of rare situation where I might want to reserve a space for something that doesn't have content yet, like a blank text file for a user to fill in when he/she has time.

like image 259
CptSupermrkt Avatar asked May 24 '12 01:05

CptSupermrkt


1 Answers

you can use FileUpload.PostedFile Property, that will give you access to the file even if the content is 0 bytes

like image 159
Kris Ivanov Avatar answered Sep 20 '22 21:09

Kris Ivanov