I'am trying to debug this code on IE. This code use AngularJS with a file input. It works fine on Chrome.
$scope.file_changed = function(element) {
var files = element.files; // FileList object
var can = document.getElementById('canvas');
var ctx = can.getContext('2d');
var photofile = element.files[0]
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
var img = new Image();
img.onload = function(){
can.width = img.width;
can.height = img.height;
ctx.drawImage(img,0,0);
}
img.src = event.target.result;
$scope.imageSource= e.target.result;
$scope.$apply();
};
})(photofile);
reader.readAsDataURL(photofile);
}// End Method file_changed
and the html :
<input ng-model="photo"
onchange="angular.element(this).scope().file_changed(this)"
type="file" accept="image/*" />
The IE debugger say : SCRIPT5007: Impossible d’obtenir la propriété « result » d’une référence null ou non définie for this ligne : img.src = event.target.result;
I have the same buf on Firefox. Does anyone have an idea ?