简体   繁体   中英

HTTP file upload: Can I rely on the browser always sending a file name?

According to this great article about HTTP uploads by Scott Hanselman, the browser typically sends a file name with the file's contents. Can I rely on the file name always being transmitted or do I have to give the user the option to enter a name if none was submitted? (If a name was submitted I do not want to prompt him for a specific reason that is not important). I would rather save myself the effort of implementing that feature if I can rely on the file name being present in all relevant browsers (meaning IE6+).

I am looking for some practical experience here. The wording of the standard is not that important to me as is the actual browser behavior today.

As ssokolow has noted you can never rely on anything coming from the client, but you can probably assume that 99% of the time you will get a filename.

Generate a filename on the possibility you dont and notify the user if you had to generate a filename.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM