The following is a summary of some problems encountered during File Upload using the HTML Control <input type = "file"> for your convenience:
1. if <input type = "file"...> </input> to select an HTML client control file, you must add the name attribute to the <input type = "file"> control. Otherwise, the server cannot obtain the control value (that is, the file)
2. by default, Asp.net has a size limit on the file to be uploaded. the maximum size is 4 MB. Check whether the file size exceeds the limit. If the limit is exceeded, no prompt is displayed except that the file cannot be uploaded. The solution is as follows: you can. add a configuration item to the config file to expand the maximum size of uploaded attachments (maxrequestlength is in KB and executiontimeout is in seconds)
<Configuration>
<System. Web>
<Httpruntime
Maxrequestlength = "1048576"
Executiontimeout = "3600"
/>
</System. Web>
</Configuration>
3. Note that the method = "Post" enctype = "multipart/form-Data" attribute must be added to form. Otherwise, the upload will fail.
4. the <input type = File> control has security restrictions. If other control events are used to trigger the Click Event of the file control, the browser first clears the value of the file control when submitting the control, the second click will be submitted, resulting in "Two click submit button issues"
Tip:
Many portal websites use their "Custom" Upload controls when sending emails or uploading files. In fact, this method is implemented through "fake, actually, the <input type = "file"> control is used. Simply put, the page uses an image like a button on the page, put a file control in front and set its transparency to 0. In this way, you can click the "Upload File" image button to set the file control value, then, the onchange event of the file control puts the file name in the Custom upload control on the page ". If you are interested, you can search for specific implementation methods on the Internet.