Martin
Martin

Reputation: 11336

Dropzone.js: how to cancel uploads when dropping new file

Using Dropzone.js I need to implement a way when a user drop a file into Dropzone all current uploads (if any) are canceled so only the current one gets uploaded.

I need a way to select and delete those.

I can do MyDropzone.processQueue to get the uploading queue files. I can also do MyDropzone.removeAllFiles() but this removes all items (uploading or uploaded).

I don't understand how can I apply the removeAllFiles() method only to the files that are in MyDropzone.processQueue.

Any idea how to accomplish this?

Upvotes: 3

Views: 7801

Answers (2)

Breith
Breith

Reputation: 2298

Try:

Dropzone.autoDiscover = false;
$("#mydropzone").dropzone({
    init: function() {
        var $this = this;
        $("button#clear-dropzone").click(function() {
            $this.removeAllFiles(true);
        });
    }
});

Upvotes: 1

enyo
enyo

Reputation: 16696

The latest version of Dropzone provides methods for this, as well as a addRemoveLinks option that inserts links to cancel/remove uploads.

Upvotes: 1

Related Questions