5. File Upload
-"NOTE: Using the HTTP protocol is only suitable for transferring small files, if you want to pass large files, you need to use plug-in or client program (using FTP protocol)
-"Client action"
"1"adds attributes to the form:enctype= "Multipart/form-data"
"2"adding Controls to the form:<input type= "file" name= "F1"/>
"3" form must use post submission method
-"server-side operations"
"1" using the request.files property to get the file object
2Savewith the SaveAs () method of the httppostedfile Object
-"Observe the data message
When you set the enctype= "Multipart/form-data" property of a form, it is no longer the key-value format, but instead uses the delimiter in the request body
-"limit: Upload executable file is not allowed, only allow static file upload
Example: Only upload images are allowed
Client-side Checksum
Server-side Check
-"Improve: Save the file to the corresponding year, month, and Day folder for easy traversal
Dynamically creating paths
Stitching path Information
Example:ASPNET Project Review / /t1_upload_downloadof the next day
6. File Download
-"Use hyperlinks to directly specify the files to download
Text that can be parsed by the browser will be displayed
Files that cannot be parsed by the browser will be downloaded
-"Implementation: No matter the file format, do not use the browser display, complete the download
Point to generic handler, file address as parameter
Modify the response header:ContentType = "Application/octet-stream";
Set header information:addheader ("content-disposition", "attachment; Filename=\ " file name \"; ");
Output file:context. Response.WriteFile ( file address );
-"Hint: If the Chinese file name is garbled, URL encoding can be
Httputility.urlencode (filename, System.Text.Encoding.UTF8);
Returns a string as the name of the file
Example:ASPNET Project Review / /t1_upload_downloadof the next day
Asp. NET Knowledge Summary (5. File upload 6. File download)