-
-
Notifications
You must be signed in to change notification settings - Fork 167
ng file upload
Martin Kluska edited this page May 31, 2018
·
1 revision
Package | handler class |
---|---|
Github | NgFileUploadHandler |
- Read the official docs
- Create the view as package requires
- Implement the basic ng-file-upload code (you need to set the resumeChunkSize)
$scope.upload = function (file) {
file = Upload.upload({
url: 'http://yourapi.com/upload',
data: { file: file, your_additionnal_data: 'foo' },
resumeChunkSize: '5MB'
});
file.upload.then(function (response) {
/**
* User response after download as you need
*/
}, function (response) {
if (response.status > 0) {
/**
* Handle error as you need
*/
}
}, function (evt) {
// Math.min is to fix IE which reports 200% sometimes
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
};