dropzone.js `maxfilesexceeded` event is not getting fired. When adding files programatically

297 Views Asked by At

I am using dropzone in my vuejs project. I have set maxFiles: 1 in my dropzone options.

Now I have to show existing file from server in dropzone so i am using this code to add existing file in my dropzone.

let mockFile = { name: 'Filename', size: file.size };
myDropzone.emit('addedfile', mockFile);
myDropzone.emit('thumbnail', mockFile, file.dataURL);
myDropzone.emit('success', mockFile);
myDropzone.emit('complete', mockFile);
myDropzone.files.push(file);

This code is working fine and file is getting added in the dropzone. However when i add more files(manually) to that dropzone the maxfilesexceeded event is not getting fired.

Note: if i add files manually instead of programatically then it is firing maxfilesexceeded event.

1

There are 1 best solutions below

1
On

use this after push Every item to files list:

myDropzone._updateMaxFilesReachedClass();