jquery-filedrop icon indicating copy to clipboard operation
jquery-filedrop copied to clipboard

Can't upload files over 4096k (4MB)

Open xmuskrat opened this issue 13 years ago • 6 comments

These seem to end up landing on the server with an empty $_files in PHP. I've verified my upload_max_filesize and post_max_size are large enough to handle the size. However, the more I research into this, it looks like a max limit of an XMLHTTPRequest.

Looks like other file uploaders have the option to split the file into several XMLHTTPConnections for files that go over the max size. This would be a cool option to wrap into your uploader.

xmuskrat avatar Sep 09 '11 06:09 xmuskrat

Something along the lines of this:

Slicing a file and uploading each portion

Using the File APIs, we can minimize the work to upload a large file. The technique is to slice the upload into multiple chunks, spawn an XHR for each portion, and put the file together on the server. This is similar to how GMail uploads large attachments so quickly. Such a technique could also be used to get around Google App Engine's 32MB http request limit.

window.BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder ||
                     window.BlobBuilder;

function upload(blobOrFile) {
  var xhr = new XMLHttpRequest();
  xhr.open('POST', '/server', true);
  xhr.onload = function(e) { ... };
  xhr.send(blobOrFile);
}

document.querySelector('input[type="file"]').addEventListener('change', function(e) {
  var blob = this.files[0];

  const BYTES_PER_CHUNK = 1024 * 1024; // 1MB chunk sizes.
  const SIZE = blob.size;

  var start = 0;
  var end = BYTES_PER_CHUNK;

  while(start < SIZE) {

    // Note: blob.slice has changed semantics and been prefixed. See http://goo.gl/U9mE5.
    if ('mozSlice' in blob) {
      var chunk = blob.mozSlice(start, end);
    } else {
      var chunk = blob.webkitSlice(start, end);
    }

    upload(chunk);

    start = end;
    end = start + BYTES_PER_CHUNK;
  }
}, false);

})();

xmuskrat avatar Sep 09 '11 06:09 xmuskrat

Does anyone have a solution for this problem? The previous answer didn't make much sense to me.

Thanks.

skimberk avatar Jan 29 '12 03:01 skimberk

I have used this plugin for dropping files much larger than 4MB. Maybe the XMLHTTPREQUEST limit was removed?

I am succesfully uploading docs 20MB+ using chrome

mmmries avatar Apr 04 '12 20:04 mmmries

@xmuskrat - I cant seem to be able to implement your chucking solution either, can you be more specific please?

TheEngineer avatar Sep 28 '12 02:09 TheEngineer

I'm also having some issues with larger files, I'm trying to upload .mp3 files (5-10mb in size) when I drag several it freezes the tab until they are all finished, not really showing progress for each file. has chunking been implemented yet?

tsquillario avatar Nov 02 '12 13:11 tsquillario

add this to your web.config

  httpRuntime maxRequestLength="1024000" 

rajeshsahu avatar Aug 27 '13 10:08 rajeshsahu