I need to upload multiple images in a div , i try the below
angular code :
$scope.stepsModel = [];
$scope.imageUpload = function(element){
var reader = new FileReader();
reader.onload = $scope.imageIsLoaded;
reader.readAsDataURL(element.files);
}
$scope.imageIsLoaded = function(e){
$scope.$apply(function() {
$scope.stepsModel.push(e.target.result);
});
}
html code :
<input type="file" ng-model-instant name="myImage" accept="image/*" onchange="angular.element(this).scope().imageUpload(event)"/>
I got this error :
Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.
at b.$scope.imageUpload (new_ads.js:34)
at HTMLInputElement.onchange (new_ads:202)
I saw some links here ,that all for single image uploading , i need to upload multiple image one by one to a div .
Can anybody help me thanks a lot in advance .
readAsDataURL
useURL.createObjectURL(element.files[0])
instead, and don't forget to revoke the url once the image is loaded or errored – Endless Feb 7 at 15:35