ASP. File Upload Problem Resolution

Source: Internet
Author: User
Recently, a problem with the ability to upload with ASP. ASP. NET has FileUpload upload control, but this control uploads the file size is limited, so it can't meet the demand
Baidu, a lot of people have encountered the confusion of ASP. NET upload large files, occasionally search found csdn have a buddy mentioned how this super-large file implementation, RadUpload.Net2.dll and provide this dynamic library to handle the upload process of large files. So download down to see, really good results, not only support noisy 700M file upload fast, more important is to support multi-threaded upload files.
The control used to view source code discovery is also a fileupload control, but the process of processing calls is handled by RadUpload.Net2.dll.
After uploading, the file is stored under the upload folder below the bin, and the uploaded file can be renamed.

1. Create an ASPX page.
2. Create <asp:fileupload id= "FileUpload1" runat= "Server"/>.
3. Create <asp:button id= "Button3" runat= "server" text= "upload" onclick= "Button1_Click"/>
4. Upload the dynamic library process called Net2.dll in the code.
5. If you create multiple upload files, you can write several <asp:fileupload id= "FileUpload1" runat= "Server"/>.
6. Finally click the Upload button to perform the process.
The specific process is as follows

foreach (uploadedfile file in RadUploadContext.Current.UploadedFiles)            {                string Path = Server.MapPath (@ "~/ Uploads ");                If the path does not exist, create an                if (System.IO.Directory.Exists (path) = = False)                {                    System.IO.Directory.CreateDirectory ( Path);                }                Combination path, file. GetName () Gets 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.