I want to have multiple dropzones in a form. So I created a form
<form method="post">
<div class="upload-files" data-name="mainImages[]" />
<div class="upload-files" data-name="secImages[]" />
<!-- could also be more -->
<input type="text" name="test" />
<input type="submit" />
</form>
The dropzones are initialized with its own paramName.
var dropzones = [];
$('.upload-files').each(function() {
dropzones.push(new Dropzone('#' + $dropzone.attr('id'), {
paramName: $(this).data('name'),
// ...
}
);
this.dropzones = dropzones;
How to submit multiple dropzones with the form data in one request? Currently it look like this on submit.
// submit
if (this.dropzones.length) {
return true; // normal form submit without dropzone
}
// dropzone submit form
for (var i = 0, length = this.dropzones.length; i < length; i++) {
// TODO combine files with correct paramNames
}
I know this https://github.com/enyo/dropzone/wiki/Combine-normal-form-with-Dropzone but this is only for one dropzone in one form.
What I think I need todo is to add the files from the second, third, ... dropzone to the first when submitting but I dont know how to handle that.