Possible Duplicate:
Using jQuery, Restricting File Size Before Uploading
Is there a good jquery script or other method that can verify file size and file type before uploading a file to a server? I’ve tried looking all over but never found anything to do something like this.
I’d suggest the following:
JS Fiddle demo.
As JavaScript can’t remove files from the selected
fileListobject, you’d have to perform checks against the file attributes and prompt the user to deselect files that would be considered invalid due to file-type or file-size (and, obviously, prevent the form submitting):JS Fiddle demo.
(This last code tested and working in Chromium 19 and Firefox 15, both on Ubuntu 11.04.)