上传图像后清除dropzone.js缩略图
问题描述:
我已经在mvc中使用dropzone.js了解了这个教程用于上传图片,但在上传图片后,缩略图仍然显示,我需要在每次上传图片后将其删除。
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.
我试图在使用jQuery上传图像后替换生成的HTML但是它没有正确显示,因为我第一次需要刷新页面才能正确显示但我不想这样做。
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>');
答
你可以试试这个:
myDropzone.on("complete", function(file) {
myDropzone.removeFile(file);
});