Created
July 10, 2014 14:35
-
-
Save daliborgogic/c1cce5e0e1b0da029657 to your computer and use it in GitHub Desktop.
checking image size before upload
This file contains hidden or 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 x = document.getElementById('APP_LOGO'); // get the file input element in your form | |
var f = x.files.item(0); // get only the first file from the list of files | |
var filesize = f.size; | |
alert("the size of the image is : "+filesize+" bytes"); | |
var i = new Image(); | |
var reader = new FileReader(); | |
reader.readAsDataURL(f); | |
i.src=reader.result; | |
var imageWidth = i.width; | |
var imageHeight = i.height; | |
alert("the width of the image is : "+imageWidth); | |
alert("the height of the image is : "+imageHeight); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment