I have this script, it's used to fetch the width and the height of browser uploaded image.
reference: http://renevier.net/misc/resizeimg.html
function createReader(file) {
reader.onload = function(evt) {
var image = new Image();
image.onload = function(evt) {
var width = this.width;
var height = this.height;
alert (width); // will produce something like 198
};
image.src = evt.target.result;
};
reader.readAsDataURL(file);
}
for (var i = 0, length = input.files.length; i < length; i++) {
createReader(input.files[i]);
}
I want to access the value width and height from outside the createReader
function. How can I do that?
createReader
return something. That's a good start. – Elaineelamwidth
andheight
in the scope where you want to return them, such as thecreateReader
function? – Sirenasirenic