Asp. NET upload solution for large files _ practical skills

Source: Internet
Author: User

First, we need to download the component named Ranupload.

After the download is complete, two DLL files are added to the project's reference Central, and the XML files are copied to the Bin folder in the project, which means that the last three files are in the Bin folder.

Next, the upload control or the FileUpload control that comes with asp.net, what you need to add is a label next to the FileUpload control:

<radu:radprogressmanager id= "Radprogressmanager1" width= "100%" runat= "server"/> <radu
: Radprogressarea id= "progressArea1" width= "100%" runat= "Server" >
</radU:RadProgressArea>

and add the following code at the beginning of the ASPX file:

<%@ Register tagprefix= "Telerik" namespace= "Telerik.quickstart" assembly= "Telerik.quickstart"%> <%@
Register tagprefix= "RadU" namespace= "Telerik.webcontrols" assembly= "Radupload.net2"%>

Of course, the following statements cannot be forgotten in the <system.web> tab of the configuration file:

 
 

Now that the external contours have been made, the next step is to click on the server-side action after the upload:

Of course, before doing these things, let's start with the Telerik.webcontrols namespace.

Check file
if (raduploadcontext.current = null) {return;}
if (RadUploadContext.Current.UploadedFiles.Count <= 0) 
{this
. Page.ClientScript.RegisterStartupScript (this. Page.gettype (), "MsgBox", "<script>alert (' please choose to upload file!  ') </script> "); 
return;
}
if (raduploadcontext.current.uploadedfiles[0). ContentLength >= 2147483647)
{this
. Page.ClientScript.RegisterStartupScript (this. Page.gettype (), "MsgBox", "<script>alert (' uploaded files must not exceed 2GB!").  ') </script> ");
return;
}
UploadedFile file = raduploadcontext.current.uploadedfiles[0];
String fileName = Path.getfilename (file. FileName);
String virtualpath = System.IO.Path.Combine ("~/save", fileName);
String Savepath = this. MapPath (virtualpath);
File. SaveAs (Savepath, true);

At this point, the file upload processing work has been completed, the above CS code is my own some of the operation of processing, you can modify their own circumstances, as appropriate, such as also can place multiple FileUpload control,

With foreach (UploadedFile file in RadUploadContext.Current.UploadedFiles) {...} This way to handle multiple file uploads.

Hopefully this article will help friends with big file uploads headaches to easily handle uploading problems.

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.