bestprotop / jquery-multifile-plugin

Automatically exported from code.google.com/p/jquery-multifile-plugin
0 stars 0 forks source link

Add max file size constraint #195

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Would be good to be able to restrict file selection by file size out of the box.

Original issue reported on code.google.com by jamiekit...@gmail.com on 11 Apr 2014 at 1:38

GoogleCodeExporter commented 9 years ago
Javascript cannot (and don't think it will ever be able to) determine the size 
of a file. That is something this plugin will never do. But I know this can be 
done with Flash. And I think HTML5 too.

Original comment by diego.a...@gmail.com on 11 Apr 2014 at 1:59

GoogleCodeExporter commented 9 years ago
JavaScript can determine the size of a file, this is how I'm doing it now:

            onFileSelect: function (element, value, master_element) {
                if (($(element).attr('size') > 0) && (element.files[0].size > $(element).attr('size'))) {
                    alert('That file exceeds the maximum file size, please compress the file or choose a smaller file.');
                    return false;
                }
            },

Original comment by jamiekit...@gmail.com on 11 Apr 2014 at 2:35