DropZonejs: Submit form without files

后端 未结 7 1755
一生所求
一生所求 2020-12-05 14:27

I\'ve successfully integrated dropzone.js inside an existing form. This form posts the attachments and other inputs like checkboxes, etc.

When I submit the form wit

7条回答
  •  伪装坚强ぢ
    2020-12-05 15:08

    You should check if there are files in the queue. If the queue is empty call directly dropzone.uploadFile(). This method requires you to pass in a file. As stated on [caniuse][1], the File constructor isn't supported on IE/Edge, so just use Blob API, as File API is based on that.

    The formData.append() method used in dropzone.uploadFile() requires you to pass an object which implements the Blob interface. That's the reason why you cannot pass in a normal object.

    dropzone version 5.2.0 requires the upload.chunked option

    if (this.dropzone.getQueuedFiles().length === 0) {
        var blob = new Blob();
        blob.upload = { 'chunked': this.dropzone.defaultOptions.chunking };
        this.dropzone.uploadFile(blob);
    } else {
        this.dropzone.processQueue();
    }
    

提交回复
热议问题