Skip to content
vincenzoraco edited this page Aug 9, 2014 · 1 revision

For abort request use ng-click like

<button ng-click="abort()">abort</button>

$scope.onFileSelect = function($files) {
    for (var i=0; i<$files.length; i++) {
        var file = $files[i];
        $scope.upload = $upload.upload({
            url: 'path/to/server',
            method: 'PUT', // or 'POST',
            file: file
        }).progress(function(evt) {
            console.log(parseInt(100.00 * evt.loaded / evt.total) + '%');
        }).success(function(response, status, headers, config) {
            // do something
        }).error(function(response, status, headers, config) {
            // do something
        }).xhr(function(xhr) {
            // to abort, use ng-click like: ng-click="abort()"
            $scope.abort = function() {
                xhr.abort();
            };
        });
    }
}
Clone this wiki locally