以编程方式将删除的文件删除到Dropzone时出现未知问题。 这是我的代码不起作用:
// 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 );
答案 0 :(得分:22)
addedfile
函数未将文件添加到dropzone.files
所以必须手动添加:
// 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 );