Asp.net mvc 如何上传多个大文件ASP.NETMVC

Asp.net mvc 如何上传多个大文件ASP.NETMVC,asp.net-mvc,plupload,Asp.net Mvc,Plupload,这里我想指出一个代码,我从这里找到的。其目的是上传一个文件,但我的要求有点不同,比如我需要上传几个大文件,比如3个文件,每个文件大小可能是2GB [HttpPost] public ActionResult Upload(int? chunk, string name) { var fileUpload = Request.Files[0]; var uploadPath = Server.MapPath("~/App_Data"); chunk = chunk ?? 0

这里我想指出一个代码,我从这里找到的。其目的是上传一个文件,但我的要求有点不同,比如我需要上传几个大文件,比如3个文件,每个文件大小可能是2GB

[HttpPost]
public ActionResult Upload(int? chunk, string name)
{
    var fileUpload = Request.Files[0];
    var uploadPath = Server.MapPath("~/App_Data");
    chunk = chunk ?? 0;
    using (var fs = new FileStream(Path.Combine(uploadPath, name), chunk == 0 ? FileMode.Create : FileMode.Append))
    {
        var buffer = new byte[fileUpload.InputStream.Length];
        fileUpload.InputStream.Read(buffer, 0, buffer.Length);
        fs.Write(buffer, 0, buffer.Length);
    }
    return Json(new { message = "chunk uploaded", name = name });
}

$('#uploader').pluploadQueue({
    runtimes: 'html5,flash',
    url: '@Url.Action("Upload")',
    max_file_size: '5mb',
    chunk_size: '1mb',
    unique_names: true,
    multiple_queues: false,
    preinit: function (uploader) {
        uploader.bind('FileUploaded', function (up, file, data) {
            // here file will contain interesting properties like 
            // id, loaded, name, percent, size, status, target_name, ...
            // data.response will contain the server response
        });
    }
});

只是想知道有谁能告诉我,我还需要在服务器端和客户端代码上面添加什么,使我能够上传多个大文件。谢谢

您可能需要在
web.config
文件中添加一个条目,以允许较大的文件大小(2097152KB=2GB)。您可以相应调整超时时间(以秒为单位):

<system.web>
    <httpRuntime maxRequestLength="2097152" executionTimeout="3600" />
</system.web>

您还可以将请求限制(以字节为单位)设置为2GB

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483648"/>
        </requestFiltering>
    </security>
</system.webServer>


如果你瞄准的是更新的浏览器,我会强烈地考虑你看HTML5,除非你使用老浏览器,否则Flash和死一样好。这里有一些关于使用HTML5文件API的信息:您确实意识到链接已经过时了,而且它位于HTML5之前?maxRequestLength的作用是什么?maxAllowedContentLength的作用是什么?两者的区别是什么?