user782104 user782104 - 1 year ago 453
jQuery Question

How to limit the max "total" file size in dropzone.js?

Currently I use dropzone to handle the file upload in Jquery. So far it works fine.

The only problem is that, in the configuration there is a maxFileSize options , it limit the "single" file size.

And as the server (php.ini) also has a "total" file size limitation, I wonder how to limit that in the dropzone.js?

Thanks a lot.


I only see maxfilesize, paralleluploads and maxfiles

I think you may need to keep track of the file sizes as they're added, maybe using

this.on("addedfile", function(file) { // perform task // });

... tally the file sizes and disable the submit button if the total file size is exceeded.

document.getElementById('dropsubmit').disabled = false;

There are "addedFile" and "removedFile" events you could use to alter a variable tracking the file size as files are added and removed. depending on the cumulative size, set the submit button to true or false.