Hey I'm currently having a hard time with image validation in my upload form.
The problem appears within my validation / submit function called when hitting the "Submit" Button. My Plan is to check the image dimensions. I'm doing it this way:
var file = $('.html5-wrapper .mandatoryImg')[i].files[0]
$scope.image = [];
var fileReader = new FileReader();
var image = new Image();
fileReader.onload = function (event) {
image.src = event.target.result;
image.onloadend = function() {
$scope.image.push(this.width)
$scope.image.push(this.height)
// update scope after image is updated
$scope.$apply();
};
};
fileReader.readAsDataURL(file);
var img = $scope.image
console.log(img);
console.log(img[0];)
The first log delivers the desired array. But when I try to access a single value in the second log, the value is undefined!
Can anyone help?