How can I reset the dropzone in this code?

rsudip90 picture rsudip90 · Feb 11, 2014 · Viewed 20.1k times · Source
Dropzone.options.imageFile = {
    url: HOST_NAME + USER_NAME + BUILDER_API +'image/',
    method: 'POST',
    // enter code here
    acceptedFiles: '.jpg, .jpeg, .png',
    paramName: "imagefile", // The name that will be used to transfer the file
    maxFilesize: 10, // MB
    //addRemoveLinks: true,
    maxFiles: 2,
    init: function() {
        this.on("success", function(file, response) {
            image_id = response.id;
            IMAGES.push(image_id);
            check_files();
        }),
        this.on("removedfile", function(file, response){
            data = JSON.parse(file.xhr.response);
            alert(data['id']);
        });
    },
};

What I have to do to reset the dropzone completely?

Answer

Andrei Sfat picture Andrei Sfat · Feb 13, 2014

Not 100% sure I understood the question, but I presume you want to be able to reuse the dropzone instance from its original state.

Technically you want to call removeAllFiles() and that will remove all the files.

Here is an example that shows you how to add a remove all files with one button: Remove all files with one button

Also, there were other people trying to do the same thing that you are looking for: Reset dropzone to Pristine state