angularjs - Cancel Angular File Upload -
i not able cancel uploading file request angular, using below mentioned plugin upload file , according author feels way simple, not sure how should implement it. how uploading files, angular plugin files gets posted php , php intern reads entire file , streams java api through curl, so, have cancel button , once user clicks on cancel upload button need able stop upload angular plugin, once upload stopped can make call clean half streamed file....and other clean stuff.
plugin 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 ( * \ | : " < > ? / ) not allowed, in file name.', 'fail!!!', {allowhtml: true}); } });
};
it not problem plugin rather streaming, had cancel php file streaming separately cancel upload, process, not sure y? though setting user interruption false in php.ini stop php curl request once ajax request cancelled did not happen, anyway help.
Comments
Post a Comment