Created
May 18, 2016 04:29
-
-
Save AntonisFK/36b41ca5021b41b8d573bae23bb88553 to your computer and use it in GitHub Desktop.
ng-upload controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this how a controller will look if your uploading multiple files | |
$scope.uploadFiles = function (files) { | |
$scope.files = files; | |
if (files && files.length) { | |
Upload.upload({ | |
url: 'https://angular-file-upload-cors-srv.appspot.com/upload', | |
data: { | |
files: files | |
} | |
}).then(function (response) { | |
$timeout(function () { | |
$scope.result = response.data; | |
}); | |
}, function (response) { | |
if (response.status > 0) { | |
$scope.errorMsg = response.status + ': ' + response.data; | |
} | |
}, function (evt) { | |
$scope.progress = | |
Math.min(100, parseInt(100.0 * evt.loaded / evt.total)); | |
console.log($scope.progress) | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment