Clear dropzone.js thumbnail image after uploading an image

Fadi picture Fadi · Jul 17, 2014 · Viewed 46.2k times · Source

I have using dropzone.js in mvc by following this tutorial for uploading images but after uploading the image the thumbnail image still showing and I need it to be removed after every time I upload an image.

I have tried to replace the generated HTML after uploading the image using jQuery but it not showing correctly as the first time I need to refresh the page to show correctly but I don't want to do that.

 $("#ImageUpload").replaceWith('<form action="/Products/SaveUploadedFile" method="post" enctype="multipart/form-data" class="dropzone dz-clickable" id="dropzoneForm">'
 +'<div class="fallback">'
 +'<input name="file" type="file" multiple />'
 +'<input type="submit" value="Upload" />'
 +'</div>');

Answer

Giraldi picture Giraldi · May 14, 2015

You can try this:

myDropzone.on("complete", function(file) {
  myDropzone.removeFile(file);
});

More information here: http://www.dropzonejs.com/#dropzone-methods