I assume that you want to replace the old image Dropzonewhenever a new image is successfully uploaded. You can do this by combining the methods this.on('success')and this.removeFileprovided by Dropzone:
Dropzone.options.myDropzone = {
init: function() {
this.on('success', function(file, message) {
if (this.files.length > 1) {
this.removeFile(this.files[0]);
}
});
}
};
, mockFile Dropzone. , this.files init, :
var mockFile = { name: "avatar1.jpg", size: 12345, url: '/image.png' };
this.options.addedfile.call(this, mockFile);
this.options.thumbnail.call(this, mockFile, mockFile.url);
this.files = [mockFile];
:
Dropzone # SuccessEvent,
Dropzone #