I am using dropzone.js for my drag-drop file upload solution. I want to upload only one file,if i upload second file the first one should be remove and second one should be uplo
None of these solutions worked for me.
The maxfilesexceeded
event is called too late i.e. after an attempt to add the file.
Other solutions using this.removeFile(this.files[0]);
resulted in a "Uncaught TypeError: Cannot read property 'removeChild' of null".
or an infinite loop.
Solved by -
maxFiles: 2,
init: function () {
this.on("addedfile", function (file) {
if (this.files.length > 1) {
this.files = this.files.slice(1, 2);
}
});
}
Works when using dz-clickable
(file chooser btn) and drag and drop.