Skip to content

Instantly share code, notes, and snippets.

@ahilles107
Last active March 21, 2016 21:14
Show Gist options
  • Save ahilles107/b5d7edde0db3c3489a16 to your computer and use it in GitHub Desktop.
Save ahilles107/b5d7edde0db3c3489a16 to your computer and use it in GitHub Desktop.
$scope.submit = function() {
$scope.upload($scope.file);
};
// upload on file select or drop
$scope.upload = function (file) {
Upload.upload({
url: 'upload/url',
data: {file: file, 'username': $scope.username}
}).then(function (resp) {
console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
}, function (resp) {
console.log('Error status: ' + resp.status);
}, function (evt) {
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment