Check image width and height before upload with Javascript


var _URL = window.URL || window.webkitURL;
$("#file").change(function (e) {
var file, img;
if ((file = this.files[0])) {
img = new Image();
var objectUrl = _URL.createObjectURL(file);
img.onload = function () {
alert(this.width + " " + this.height);
_URL.revokeObjectURL(objectUrl);
};
img.src = objectUrl;
}
});

 

Reference:

https://stackoverflow.com/questions/8903854/check-image-width-and-height-before-upload-with-javascript/8904008



Article ID: 29
Created On: Mon, Sep 21, 2020 at 6:03 AM
Last Updated On: Mon, Sep 21, 2020 at 6:03 AM
Authored by: Saeed Nobakht [[email protected]]

Online URL: https://www.navel.ir/article/check-image-width-and-height-before-upload-with-javascript-29.html