Check image width and height
Check image width and height
by abuhamzah
HTML
<input type="file" id="file" onchange="this.files[0]" />
JavaScript
var _URL = window.URL || window.webkitURL;
var file, img;
$('input[type=file]').change(function (obj) {
alert("hola");
console.log(file);
if ((file = this.files[0])) {
img = new Image();
img.onload = function() {
alert(this.width + " " + this.height);
if (this.width > 400) {
alert('can not upload 400');
return true;
}
};
img.onerror = function() {
alert( "not a valid file: " + file.type);
};
img.src = _URL.createObjectURL(file);
}
});