I am currently using the angular-file-upload directive, and I pretty much use the exact codes from the demo.
I need to add some step to check the image size, and I can only do it now through jQuery / javascript.
Just wondering if there is an βangularβ way to check the size of an image before loading it?
$scope.uploadImage = function($files) { $scope.selectedFiles = []; $scope.progress = []; if ($scope.upload && $scope.upload.length > 0) { for (var i = 0; i < $scope.upload.length; i++) { if ($scope.upload[i] !== null) { $scope.upload[i].abort(); } } } $scope.upload = []; $scope.uploadResult = []; $scope.selectedFiles = $files; $scope.dataUrls = []; for ( var j = 0; j < $files.length; j++) { var $file = $files[j]; if ($file.type.indexOf('image') > -1) { var fileReader = new FileReader(); fileReader.readAsDataURL($files[j]); var loadFile = function(fileReader, index) { fileReader.onload = function(e) { $timeout(function() { $scope.dataUrls[index] = e.target.result;
source share