C # file upload,
I. Analysis
This blog mainly solves a series of problems such as file upload, which will be discussed in two aspects: files within 1 GB and files above 1 GB.
You can use the following three upload methods to upload files within 1 GB: use the Web Control FileUpload, html control HtmlInputFile, and Html element <input type = "file" id = "file"/> to Request. files upload.
For large files larger than 1 GB, the idea is:
(1) Protocol: http or ftp protocol can be used
(2) resumable upload
(3) Use plug-ins
(4) non-plug-in implementation
2. The file size is in the range of [0, 1G]
Upload the html control HtmlInputFile:
1. upload interface
2. Front-end code
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "myInputFile. aspx. cs" Inherits = "FileUpLoad. WebForm2" %> <! DOCTYPE html>
3. backend code
Protected void btnUpLoad_Click (object sender, EventArgs e) {// string serverpath = Server. MapPath ("~ /ImageFile "); if (file1.PostedFile. contentLength> 0) {if (File. exists (@ "C: \ Users \ WJM \ Desktop \ FilesUpLoad \" + file1.PostedFile. fileName) {Label1.Text = "the file already exists";} else {file1.PostedFile. saveAs (@ "C: \ Users \ WJM \ Desktop \ FilesUpLoad \" + file1.PostedFile. fileName); Label1.Text = "Upload successful! ";}} Else {Label1.Text =" Upload Failed ";}}
4. Configuration File
<? Xml version = "1.0" encoding = "UTF-8"?> <! -- For more information about how to configure ASP. NET applications, visit the http://go.microsoft.com/fwlink? LinkId = 169433 --> <configuration> <system. web>
Note: If you are not familiar with configuration files, refer to my other blog: ASP. NET Web. config.
Web Control FileUpload implementation
1. upload interface
3. The file size is within the range of [1G, 10G]
Note: It is not complete. Please wait .......
- Thank you for your reading. If you have any shortcomings, please kindly advise and learn and make progress together.
- Blog website: http://www.cnblogs.com/wangjiming /.
- This blog is original to bloggers.
- If you like, please recommend it; if you have new ideas, welcome to raise, mailbox: 2016177728@qq.com.
- This blog can be reposted, but it must be a famous blog source.