Recently related to using ASP.net to do the upload function of a problem, because ASP.net has fileupload upload control, but this control upload file size is limited, so simply can not meet the demand
Baidu, a lot of people encounter asp.net upload oversized file confusion, the occasional search found csdn have a buddy mentioned this oversized file how to achieve, RadUpload.Net2.dll and provide this dynamic library for processing oversized file upload process. So downloaded down to see, really good effect, not only support noisy 700M file upload fast, more important is to support multiple-threaded upload files.
View source code found that the control used is also a fileupload control, but the processing of the process call is RadUpload.Net2.dll processing.
After uploading, the file is stored under the Upload folder under Bin, and the uploaded file can be renamed.
RadUpload.Net2.dll: Download Address
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 code to call Net2.dll Dynamic Library processing process.
5. If you create multiple upload files, you can write a few more <asp:fileupload id= "FileUpload1" runat= "Server"/>.
6. Finally click the Upload button to perform the process.
The specific process is as follows
Copy Code code 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);
}
//combination path, file. GetName () gets the filename
String oldfilename = file. GetName (). ToString ();
//If the uploaded file is renamed , named after 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;
}