3

here i want to point out a code which i found from here Using plupload with MVC3. whose intention is to upload a single file but my requirement is bit different like i need to upload few large file say 3 files and each file size could be 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
        });
    }
});

just wonder anyone can tell me what else i need to add in above server side and client side code which enable me to upload multiple large files. thanks

Community
  • 1
  • 1
Thomas
  • 33,544
  • 126
  • 357
  • 626
  • 2
    If you are targeting newer browsers I would strongly consider you look at HTML5, Flash is as good as dead unless you're working with older browsers. Here's some information on using the HTML5 File API: http://www.html5rocks.com/en/tutorials/file/dndfiles/ – Mathew Thompson Jun 24 '15 at 12:56
  • http://weblog.west-wind.com/posts/2013/Mar/12/Using-plUpload-to-upload-Files-with-ASPNET – Thomas Jun 24 '15 at 17:58
  • You do realise that link is incredibly outdated and it precedes HTML5? – Mathew Thompson Jun 25 '15 at 07:16

1 Answers1

1

You might well need to add an entry to your web.config file to allow for the large file size (2097152KB = 2GB). The timeout in seconds you can adjust accordingly:

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

also you can set request limit (which is in bytes) to be 2GB,

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483648"/>
        </requestFiltering>
    </security>
</system.webServer>
scgough
  • 5,099
  • 3
  • 30
  • 48
  • what maxRequestLength does? and what maxAllowedContentLength does? and difference between two? – Thomas Jun 24 '15 at 17:57