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; }