First of all, you can test the following piece of code
<formID= "Form1"runat= "Server"> <inputtype= "File"name= "TTT" /> <inputtype= "Submit"value= "Tap" /> </form>
And then in the background
var files= request.files;
You'll find there's nothing in files,
Why, the original is the form did not upload file, because a property in mischief Enctype
Because the form has a property Enctype property, enctype specifies how the form data should be encoded before being sent to the server.
By default, the form data is encoded as "application/x-www-form-urlencoded". That is, all characters are encoded before being sent to the server (spaces are converted to "+" plus signs, and special symbols are converted to ASCII HEX values).
| value |
Description |
| application/x-www-form-urlencoded |
Encode all characters before sending (default) |
| Multipart/form-data |
Character encoding is not. You must use this value when you use a form that contains a file upload control. |
| Text/plain |
Spaces are converted to "+" plus signs, but special characters are not encoded. |
From the above table enctype the value can be seen, the default will encode all characters, when there are files uploaded directly discarded.
It's time to replace
<formID= "Form1"runat= "Server"enctype= "Multipart/form-data"> <inputtype= "File"name= "TTT" /> <inputtype= "Submit"value= "Tap" /> </form>
Can. Note that input file must have the name attribute, or it will not be uploaded.
Form uploading files for HTML