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 a third-party Upload component.NeatuploadHowever, the node configuration required by the node fails. The custom configuration section described in this article is different from the official settings. If you run the official code, the node configuration fails. Another one is 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:
Determine the file size.Activex (fso)Method pairDifferent browsers and permissions are restricted.,Another methodThis seems to be the case. Give up.
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 in the code, as shown in the following figure.
Set in web. config so that 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 download file list. The code is as follows:
Click the button to download the selected file. The code is as follows: