取消 Angular 文件上传

Cancel Angular File Upload

我无法取消来自 angular 的上传文件请求,我正在使用下面提到的插件上传文件,根据作者的说法,这感觉很简单,但我不知道我应该如何实施它。这就是我上传文件的方式,从 Angular 插件文件发布到 php 并且 php 实习生读取整个文件并将其流式传输到 java api通过 curl,所以,现在我有一个取消按钮,一旦用户点击取消上传按钮,我需要能够停止从 angular 插件上传,所以一旦上传停止,我可以再次调用 clean半流文件....和其他清理东西。

插件Link:https://github.com/danialfarid/ng-file-upload

$scope.uploadFiles = function(files) {

if(files != undefined){
    $scope.currentFileUploadList = files;
    $scope.$apply();
}
angular.forEach(files, function(file, key) {
    if(isSpecialChar(file.name)){
        //$scope.currentFileUploadList[key].status = false;
        //$scope.$apply();
        file.upload = Upload.upload({
            url: $scope.BASE_FOLDER+'/sync/file/upload',
            fields: {csrf_token: $('.csrf_token').html(), path: 'ParaBlu'},
            file: file
        });

        file.upload.then(function (response) {
            $timeout(function () {
                file.result = response.data;
                if(response.data.result == 'success'){
                    $('.status').hide();
                    toastr.success(response.data.file.fileName+' has been uploaded successfully', 'Successfully!!!', {allowHtml: true});
                    $scope.currentFileUploadList.forEach(function(value, key){
                        if(value.name.toString() == response.data.file.fileName.toString()){
                            $scope.currentFileUploadList.splice(key, 1);
                        }
                    });
                    if((files.length) == key){
                        $('#uploadFiles').modal('hide');
                    }
                }else{
                    toastr.error(file.name, response.data.msg, 'Fail!!!', {allowHtml: true});
                }
            });
        }, function (response) {
            if (response.status > 0)
                $scope.errorMsg = response.status + ': ' + response.data;
        });

        file.upload.progress(function (evt) {
            file.progress = Math.min(100, parseInt(100.0 *
                evt.loaded / evt.total));
        });
    }else{
        $scope.currentFileUploadList.forEach(function(value, key){
            if(value.name.toString() == file.name.toString()){
                $scope.currentFileUploadList.splice(key, 1);
            }
        });
        toastr.error('Special characters like ( * \ | : " < > ? / ) are not allowed, in a file name.', 'Fail!!!', {allowHtml: true});
    }
});

};

这不是插件的问题,而是流式传输的问题,我不得不单独取消 php 文件流式传输以取消上传、处理,不确定是吗?我虽然在 php.ini 中将用户中断设置为 false 也会在 ajax 请求被取消后停止 php curl 请求,但它没有发生,无论如何感谢您的帮助。