I am using dropzone to upload multiple files to my upload script, which saves them and adds them and adds them to my DB. There is a problem, in that files sometimes upload so fast that the backend script gets confused and sometimes processes the same file twice. My proposed solution is to upload a file, wait for a callback from the PHP script, then upload the next one.
This should be possible with Dropzones options, but I can't get it to work.
var dropZoneOptions = {
paramName: "file",
maxFilesize: 100, // MB
addRemoveLinks: true,
dictRemoveFile: 'Go away',
createImageThumbnails: true,
addRemoveLinks : true,
uploadMultiple: false,
parallelUploads: 1,
autoProcessQueue: false,
addedFile: function() {
this.on("addedfile", function(file) {
processFile(file);
alert("Added file.");
});
},
success:function(file,response){
this.on("success", function(file) {
enqueueFile(file);
console.log(file);
})
}
};
The idea is for the above code to pause (autoProcessQueue: false) to wait for a response then use the enqueue file command to continue the next one (parallelUploads: 1). But my code above doesn't run the queue.
The docs for the enqueue function are here: http://www.dropzonejs.com/#enqueuing-file-uploads
Any Dropzone experts out there who can help me? Thanks in advance.