Created
February 12, 2017 17:50
-
-
Save LCHCAPITALHUMAIN/7ad10f915238bfc562ad0a8b921f3b5f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // upload list of files | |
| $scope.onFileSelect = function ($files) { | |
| //$files: an array of files selected, each file has name, size, and type. | |
| for (var i = 0; i < $files.length; i++) { | |
| $scope.uploading = {}; | |
| var file = $files[i]; | |
| var upload_data = { | |
| url: apiBase, | |
| method: 'POST', | |
| headers: {'X-CSRFToken': CSRF.token() }, | |
| file: file | |
| }; | |
| var progress = function (evt) { | |
| $scope.uploading.percent = parseInt(100.0 * evt.loaded / evt.total); | |
| }; | |
| var success = function (data, status, headers, config) { | |
| // file is uploaded successfully | |
| loadItems($scope.pagination.page, $scope.pagination.limit); | |
| loadMediaTypes(); | |
| $scope.uploading = false; | |
| }; | |
| var error = function(data, status) { | |
| Alert.push(Alert.type.danger, 'Your files could not be uploaded at this time, please try again later'); | |
| $scope.uploading = false; | |
| }; | |
| $scope.upload = $upload.upload(upload_data).progress(progress).success(success).error(error); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment