_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; }}
I want to get true or false in result. But it always give me false. and it get alert before the condition in function