Home  >  Article  >  Backend Development  >  Solving the problem of uploading large files in Asp.Net

Solving the problem of uploading large files in Asp.Net

高洛峰
高洛峰Original
2016-12-29 16:55:121449browse

Recently, there is a problem related to using asp.net for upload function, because asp.net has fileupload upload control, but the size of the file uploaded by this control is limited, so it cannot meet the demand at all
Baidu checked it, many people Encountered the confusion of uploading very large files in asp.net. I accidentally searched and found that a buddy in csdn mentioned how to implement this very large file. RadUpload.Net2.dll also provides this dynamic library to handle the upload process of very large files. So I downloaded it and took a look, and the effect was indeed good. Not only does it support fast file uploads exceeding 700M, but more importantly, it supports multi-threaded file uploads.
Looking at the source code, I found that the control used is also the fileupload control, but the processing process is called RadUpload.Net2.dll.
After uploading, the file is stored in the upload folder under bin, and the uploaded file can be renamed.

1. Create an aspx page.
2. Create e617303961ba735775f26cbdb39ca32c.
3. Createc2f377b9b5b6fec8597d99238849bcae
4. Call the dynamic library processing of net2.dll in the upload code process.
5. If you create multiple upload files, you can write several more e617303961ba735775f26cbdb39ca32c.
6. Finally, click the upload button to execute the processing.
The specific process is as follows

 foreach (UploadedFile file in RadUploadContext.Current.UploadedFiles)
            {
                string Path = Server.MapPath(@"~/Uploads");
                //如果路径不存在,则创建
                if (System.IO.Directory.Exists(Path) == false)
                {
                    System.IO.Directory.CreateDirectory(Path);
                }
                //组合路径,file.GetName()取得文件名
                string oldfilename = file.GetName().ToString();
                //如果对上传后的文件进行重新命名,根据guid进行命名,则放开下面二行代码
                //string fileType = oldfilename.Substring(oldfilename.LastIndexOf("."));
                //string newfilename = Guid.NewGuid().ToString("N") + fileType;
                //Path = Path + "/" + file.GetName().ToString();
                Path = Path + "/" + oldfilename;
                //保存
                file.SaveAs(Path, true);
                string newurl = @"~/Uploads/" + oldfilename;              
            }


For more articles related to solving Asp.Net oversized file upload problems, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn