Last active
December 20, 2015 00:48
-
-
Save spsaucier/6044072 to your computer and use it in GitHub Desktop.
Disallow large file uploads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Disallows uploads over 2Mb | |
$(document).on('change', 'input[type=file]', function() { | |
//this.files[0].size gets the size of your file. | |
if (this.files[0].size > 2097152 || this.files[0].filesize > 2097152) { | |
alert('Your file is too large (over 2Mb). Please use a smaller file.') | |
$(this).wrap('<form>').closest('form').get(0).reset(); | |
$(this).unwrap(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment