How can I take value of w
and h
out side the below code. I need to get the width and height of each image that is selected to upload.
var widt;
var hit;
reader.readAsDataURL(file);
reader.onload = function (_file) {
image.src = _file.target.result; // url.createObjectURL(file);
image.onload = function () {
var w = this.width,
h = this.height,
t = file.type, // ext only: // file.type.split('/')[1],
n = file.name
widt = w;
hit = h;
};
};
console.log(widt);
Here console.log
returns undefined
.