我有以下代码,我正在检查图像的高度和宽度。 这是脚本的一部分。请帮帮我。提前致谢
_filesCheck: function() {
var result = false;
if(n.ftype=='image')
{
var reader = new FileReader();
//Read the contents of Image File.
reader.readAsDataURL(f.files[0]);
reader.onload = function (e) {
//Initiate the JavaScript Image object.
var image = new Image();
//Set the Base64 string return from FileReader as source.
image.src = e.target.result;
//Validate the File Height and Width.
image.onload = function () {
var height = this.height;
var width = this.width;
if (height != n.hsize && width != n.wsize) {
alert("Width and Height must "+n.wsize+"x"+n.hsize+"");
result = false;
return false;
}
/*alert("Uploaded image has valid Height and Width.");*/
result = true;
return true;
};
}
alert(result);
return result; }}
我想在结果中得到真或假。但它总是让我虚伪。它在功能
之前得到警报