[Vuejs]-VueJS dropzone does not working properly on drag/drop

0๐Ÿ‘

โœ…

I found that there is a delay when user drag a file.
So I have fixed this issue using timeout in dropzone option like following.

dzOptions: {
    url: self.$apiUrl + "client/documents/",
    autoProcessQueue: false,
    acceptedFiles: "application/pdf",
    uploadMultiple: false,
    maxNumberOfFiles: 1,
    maxFilesize: 30,
    addRemoveLinks: true,
    dictDefaultMessage:
        "Select File",
    init: function() {
        this.on("addedfiles", function(files) {
            var dz = this;
            setTimeout(function() {
                self.upload();
            }, 500);
        });
    }
}
๐Ÿ‘คLi Y

0๐Ÿ‘

You are accessing your references like this:

self.$refs.docfile.dropzone

Try like this:

self.$refs.docfile

As per the files, you could get them with the: getAcceptedFiles(), getRejectedFiles(), getQueuedFiles() methods.


Some example on how to use vue-uploads events:

data: () => ({
    dropzoneOptions: {
      ...
    },
    myFiles: []
}),
<vue-dropzone ref="myVueDropzone" id="dropzone"
    :options="dropzoneOptions"
    @vdropzone-success="filesUploaded">
</vue-dropzone>
filesUploaded(event){
    this.myFiles.push(JSON.parse(event.xhr.response));
},
๐Ÿ‘คErubiel

Leave a comment