I'm having troubles in setting dropzone JS in a pre existing form, in which I have to load multiple files.
I have an existing asp.net form (with an antiforgery token), and I've set up the Dropzone as follows:
const dz = new Dropzone(".dropzonecreate", {
uploadMultiple: true,
parallelUploads: 100,
maxFiles: 100,
autoProcessQueue: false,
previewpreviewsContainer: "#dropzonePreview",
clickable: "#dropzonePreview",
url: "/InserzioneMoto/Create",
// The setting up of the dropzone
init: function () {
var myDropzone = this;
document.getElementById('InsertInserzione').addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
//Even with two or more files this got triggered
this.on("sending", function (data, xhr, formData) {
var data = $('#dZUpload').serializeArray();
$.each(data, function (key, el) {
formData.append(el.name, el.value);
});
});
//This never get triggered
this.on("sendingMultiple", function (data, xhr, formData) {
var data = $('#dZUpload').serializeArray();
$.each(data, function (key, el) {
formData.append(el.name, el.value);
});
});
},
maxFilesize: 100,
acceptedFiles: ".jpeg, .jpg, .png",
dictDefaultMessage: "<strong>Trascinare i file o cliccare per sfogliare</strong><br/>sono ammessi solo .jpeg o .jpg fino a 100 MB",
dictFallbackMessage: "Il browser non supporta il trascinamento di files, usare: chrome, ie, opera, safari, firefox o edge",
dictFileTooBig: "File Troppo Grande ({{filesize}}). Il limite è fissato a {{maxFilesize}}.",
dictInvalidFileType: "Il tipo di file non è fra quelli permessi. sono ammessi solo file .jpeg, .jpg, .png",
dictResponseError: "Server non disponibile. codice errore {{statusCode}}",
dictRemoveFile: "Rimuovi file"
});
I have an existing div #DropzonePreview
that'll contain the loaded files until the request has been sent. I've set uploadMultiple
, with the parallelUploads
and maxFiles
. Yet it still sends file one by one (with the same antiforgery token, so the request can't be fullfilled).
If I have one single file the request works flawlessly and I can get the file from Request.Files
.
Does anyone has any idea?
Thanks in advance.