I have implemented image upload functionality using Dropzonejs
in a form. To handle multiple form fields, I have set autoProcessQueue
to false
and processing it on click of the Submit button as shown below.
Dropzone.options.portfolioForm = {
url: "/user/portfolio/save",
previewsContainer: ".dropzone-previews",
uploadMultiple: true,
parallelUploads: 8,
autoProcessQueue: false,
autoDiscover: false,
addRemoveLinks: true,
maxFiles: 8,
init: function() {
var myDropzone = this;
this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
}
}
While this functionality works well for uploading images, I also want to display previously uploaded images when the form is edited. I found a helpful resource in the Dropzone Wiki that explains how to show existing files stored on the server: https://github.com/enyo/dropzone/wiki/FAQ#how-to-show-files-already-stored-on-server
Although this method populates the dropzone-preview
area with existing images, it does not include these images in the form submit. I believe this is because the images are not added to the queue
. In this case, how can I handle updates on the server side if a user removes an existing image?
Additionally, what would be the preferred approach: adding previously uploaded images to the queue
again or simply sending information about the removed file?