There is a unknown problem while programmatically deleting programmatically added files to Dropzone. Here is my code that is not working:
// constructor - OK
docsDropzone = new Dropzone( "#docsUpload", {
url: uploadUrl,
addRemoveLinks: true,
init: function() {
this.on( 'removedfile', removedFileCallback );
}
} );
// add file - OK
var mockFile = { name: 'test.jpg', size: 0 };
docsDropzone.emit( "addedfile", mockFile );
docsDropzone.emit( "thumbnail", mockFile, 'test.jpg' );
// remove files - NOT OK
docsDropzone.removeAllFiles( true );
dropzone has the following function for removing all files. If you want to remove all files, simply use . removeAllFiles().
If you want to remove an added file from the dropzone, you can call . removeFile(file) . This method also triggers the removedfile event. myDropzone.
Dropzone. js is 'a light weight JavaScript library that turns an HTML element into a "dropzone"'. Users can drag and drop a file onto an area of the page, uploading to a server. If you would like to read more how all of this works skim through the Dropzone.
addedfile
function is not adding files to dropzone.files
so it must be added manually:
// add file - OK
var mockFile = { name: 'test.jpg', size: 0, status: 'success' };
docsDropzone.emit( "addedfile", mockFile );
docsDropzone.emit( "thumbnail", mockFile, 'test.jpg' );
docsDropzone.files.push( mockFile ); // file must be added manually
// remove files - NOW OK
docsDropzone.removeAllFiles( true );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With