How can I disable the Dropzone after uploading 1 image and enable again when I push a button

101 views Asked by At

I want to disable the dropzone after uploading 1 file and enable it after clicking a button

disable the dropzone after uploading 1 file

<form action="/file-upload" class="dropzone" id="my-awesome-dropzone" disabled="true"></form>

Button that enable the dropzone

<form action="/file-upload" class="dropzone" id="my-awesome-dropzone"></form>
1

There are 1 answers

1
Zandrei Canete On

Instead of disabling it I replace the currently uploaded file with the new upload or new dropped file

const _dropZone = $("#my-awesome-dropzone").dropzone({
      maxFiles: 1,
      uploadMultiple: false,
      init: function () {
        this.on("addedfile", function () {
          if (this.files[1] != null) {
            this.removeFile(this.files[0]);
          }
        });
      },
    });