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

3
  • 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: html5rocks.com/en/tutorials/file/dndfiles Commented Jun 24, 2015 at 12:56
  • weblog.west-wind.com/posts/2013/Mar/12/… Commented Jun 24, 2015 at 17:58
  • You do realise that link is incredibly outdated and it precedes HTML5? Commented Jun 25, 2015 at 7:16

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

1 Comment

what maxRequestLength does? and what maxAllowedContentLength does? and difference between two?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.