Asp. Net ultra-large file upload Solution

Source: Internet
Author: User

Recently, asp.net is involved in the upload function. asp.net has a fileupload upload control, but the file size uploaded by this control is limited, so it cannot meet the requirements.
Baidu, many people encounter asp.net's confusion about uploading ultra-large files. The occasional search found that csdn's buddy mentioned how to implement this ultra-large file, RadUpload. net2.dll also provides this dynamic library for uploading and processing large files. As a result, I downloaded the file and looked at it. The effect was good. It not only supported fast uploading of files with a MB quarrel, but also supported multi-threaded uploading of files.
The controls used to view the source code are also the fileupload control, but the processing process calls RadUpload. Net2.dll.
The uploaded file is stored in the upload folder under bin, and the uploaded file can be renamed.

RadUpload. Net2.dll:


1. Create An aspx page.
2. Create <asp: FileUpload ID = "FileUpload1" runat = "server"/>.
3. Create <asp: Button ID = "Button3" runat = "server" Text = "Upload" OnClick = "button#click"/>
4. Upload the dynamic library processing process that calls net2.dll in the code.
5. If you create multiple upload files, you can write more <asp: FileUpload ID = "FileUpload1" runat = "server"/>.
6. Click the upload button to perform the processing.
The procedure is as follows:
Copy codeThe Code is as follows:
Foreach (UploadedFile file in RadUploadContext. Current. UploadedFiles)
{
String Path = Server. MapPath (@"~ /Uploads ");

// If the path does not exist, create
If (System. IO. Directory. Exists (Path) = false)
{
System. IO. Directory. CreateDirectory (Path );
}

// Combined path, file. GetName () to get the file name
String oldfilename = file. GetName (). ToString ();

// If you rename the uploaded file and name it according to the guid, release the following two lines of code:
// String fileType = oldfilename. Substring (oldfilename. LastIndexOf ("."));
// String newfilename = Guid. NewGuid (). ToString ("N") + fileType;
// Path = Path + "/" + file. GetName (). ToString ();
Path = Path + "/" + oldfilename;

// Save
File. SaveAs (Path, true );
String newurl = @"~ /Uploads/"+ oldfilename;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.