I want to use Dropzone in .net8 MVC project with autoProcessQueue option set to false.
I'm trying with this https://stackoverflow.com/questions/58815724/how-to-integrate-dropzone-js-with-asp-net-core-mvc.
The problem is that controller isn't receive files. This only happen if autoProcessQueue is false. Otherwise it receive the file.
The code is this:
HTML
<form asp-action="ProcessImages" method="post" enctype="multipart/form-data" class="dropzone" id="dropzoneForm">
<div class="form-group form-actions">
<div class="col-md-9 col-md-offset-4">
<button type="submit" id="submit" class="btn btn-sm btn-primary"> Upload</button>
</div>
</div>
<span class="text-danger" id="error-message"></span>
</form>
JQuery
function myParamName() {
console.log("executed");
return "ModelImages";
}
let myDropzone;
Dropzone.options.dropzoneForm = {
paramName: myParamName,
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
maxFilesize: 5242880, // Bytes
maxFiles: 5,
acceptedFiles: "image/*",
addRemoveLinks: true,
dictDefaultMessage: "Drag and drop the images. Max 5 images of 5Mb each.",
dictRemoveFile: "Remove",
init: function () {
console.log("active");
myDropzone = this;
$("#submit").click(function (e) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
},
accept: function (file, done) {
console.log({ myDropzone });
done();
}
}
And Controller method signature:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> ProcessImages([FromForm] List<IFormFile> ModelImages)
Only if autoProcessQueue is true ModelImages have a file.