Created
February 27, 2019 07:11
-
-
Save vasilii-b/d52bf0b4520ee245cd1c2f9ae4ff01ff to your computer and use it in GitHub Desktop.
Checks whenever the uploaded file matches allowed file maximum size
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
var uploadField = document.getElementById("file"); | |
uploadField.onchange = function() { | |
if(this.files[0].size > 2097152){ // 2MB | |
alert("File is too big!"); | |
this.value = ""; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment