estani
estani

Reputation: 26547

dropzone "You can not upload any more files" after error with maxFiles:1

When an error happens, and maxFiles is set to 1, dropzone does not try to upload another file.

It somehow thinks it already have updated the file.

$(this.element).dropzone({
      maxFiles: 1,
      createImageThumbnails: false,
      dictDefaultMessage: '',
      clickable: true,
      paramName: this.paramNameValue,
      url: this.urlValue,
      method: this.methodValue,
      init: function() {
        this.on("error", (fileObject, response) => {
          let msg
          try {
            msg = JSON.parse(response).join(', ')
          } catch (e) {
            msg = response;
          }
          console.log('error', msg)

        });
      }
    })

Upvotes: 0

Views: 1490

Answers (2)

Rahul Singh Rawat
Rahul Singh Rawat

Reputation: 1

add maxFiles:1, in new Dropzone();

      myDropzone.on("addedfile", function (file) {
          for (var i = myDropzone.files.length - myDropzone.maxFiles -1; i >= 0; i--) {
              var f = myDropzone.files[i];
              if (f.upload.uuid !== file.upload.uuid)
                  myDropzone.removeFile(f);
          }
      });

Upvotes: 0

estani
estani

Reputation: 26547

As @DBS mentions I found the solution to be to manually remove the file.

This is how it looks:

$(this.element).dropzone({
      // ....
      init: this.on("error", (fileObject, response) => {
          this.removeAllFiles();
          // ...
        });
      }
    })

Upvotes: 1

Related Questions