简体   繁体   中英

How to remove all files from dropzone after uploading

I have created a dropzone using ng-dropzone

  myApp.config(function(dropzoneOpsProvider) {
  dropzoneOpsProvider.setOptions({
    url: 'url',
    acceptedFiles: 'image/jpeg, images/jpg, image/png',
    addRemoveLinks: true,
    dictDefaultMessage: 'Click to add or drop photos',
    dictRemoveFile: 'Remove photo',
    dictResponseError: 'Could not upload this photo',
    maxFilesize: 100,
    uploadMultiple: true,
    parallelUploads: 5,
    maxFiles: 10
   });
});

myApp.controller('topStoryController',
    $scope.dzOptions = {
        paramName: 'file',
        maxFilesize: '10'
    }; $scope.dzCallbacks = {
        'successmultiple': function(file, xhr) {
            console.log('uploaded ' + file.name);
            console.log(file, xhr);
            console.log(xhr.path);
        },
    };


    $scope.post = function() {

    }

); Here I am uploading multiple image using dropzone that is working properly after imaaging upload on post I want to remove images from dropzone.

how to achive this?

dropzone has the following function for removing all files.

removeAllFiles();

documentation of dropzone explains this function as following

If you want to remove all files, simply use .removeAllFiles(). Files that are in the process of being uploaded won't be removed. If you want files that are currently uploading to be canceled, call .removeAllFiles(true) which will cancel the uploads.

documentation of the ng-dropzone directive states that you can access dropzone functions using the following

$scope.dzMethods.removeFile(file);

or

<button ng-click="dzMethods.removeAllFiles();">...</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM