简体   繁体   中英

Deleting uploaded files form Dropzone.js form

I'm using dropzone.js for my project and I need to delete files from plugin upload zone (not from server) after I upload them. I need to get back to "Drop files here or click to upload" text after upload.

I'm trying to get same result that I would get when I'm using "Remove file" link under file icon. But when I try to achieve this programmatically the removeFileEvent won't trigger.

I tried both jquery trigger('click'); and dispatchEvent(event); .

My code:

 var dropzone = new Dropzone('#uploadzone', 
    {
       url: 'uploaded_url.php',
       addRemoveLinks: true,
       init: function () 
       {
           this.on("success", function (file, response) 
           {
              var removeLink = $(file.previewElement).find('a.dz-remove');
              removeLink.trigger('click');
           });
       }
    );

You can use the API given by dropzone

dropzone.removeFile(file)

Docs

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