When uploading a large file, you must configure it in the web. config file and add the following nodes to the <system. web> node:
<Httpruntime usefullyqualifiedredirecturl = "true" maxrequestlength = "204800" executiontimeout = "900"/>
The maxrequestlength attribute sets the maximum size of a file that can be uploaded. The unit is kb. The default value is 4 MB. The maximum value can be set to 2 GB. If the size is exceeded, asp tutorial. net will not make any response, the setting here is 200 m.
In this way, the upload control fileupload provided by the asp.net tutorial can upload large files. If the chrome browser is used, the transfer progress will be seen in the lower left corner, but not in ie.
To display a good upload progress bar, you can use the third-party Upload Component neatupload, but the node configuration is not successful. The custom configuration section described in this article is different from the official settings, I failed to run the official code and gave up. There is also a charged aspnetupload.
Determine the file type and size on the client:
Determine the file type. The Code is as follows:
You can also use the onclientclick attribute of the button control. Note that there is a return before the client event. If the return value is false, The onclick event is not executed. The Code is as follows:
To determine the file size, activex (fso) is used to restrict different browsers and permissions. This is also true for another method.
Determine the file type and size on the server side (if the file to be uploaded is large, the size will be determined for a long time ):
The code is written to the Code, such
In web. config, you can change the type and size of the file to be uploaded at any time. The Code is as follows:
The configuration in the ettings configuration section of the apps tutorial in web. config is as follows:
Download the file using system. io:
First, obtain the list of downloaded files. The Code is as follows:
Click the button to download the selected file. The Code is as follows: