I am new to dropzone js but this plugin looks amazing. I want to use dropzone js to save multiple files but according to the Document type. Means I have Doc Type like,
@Html.DropDownList("LKP_DocType", null, " ", htmlAttributes: new { @class = "form-control", @required = "required" })
Its Values for Document type are
ID Name
1 Administrator
2 Manager
3 Programer
and I can only upload total of 5MB files per Document Type
Means I can upload only PDF type documents for administrator but total size of documents not exceed 5MB.
I already use Drop zone as mentioned in my code below where I am restricting PDF attachment 5MB.
Razor View
<form action="~/Employees/Upload" class="dropzone " id="dropzoneJsForm" style="background-color: #7dc1d8">
<div> @Html.DropDownList("LKP_DocType", null, " ", htmlAttributes: new { @class = "form-control", @required = "required" })</div>
</form>
$(document).ready(function () {
Dropzone.options.dropzoneJsForm =
{
autoProcessQueue: false,
maxFilesize: 5,
acceptedFiles: ".pdf",
init: function () {
this.on("addedfile", function (file) {
var removeButton = Dropzone.createElement("<button class='btn btn-danger' style='margin-top:4%;border-radius: 12px;'>Remove</button>");
var _this = this;
removeButton.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
_this.removeFile(file);
});
file.previewElement.appendChild(removeButton);
});
}
};
});
Controller
public ActionResult Upload()
{
foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
}
return Json(new
{
Message = "Files Saved"
});
}
I am using autoProcessQueue: false to later add submit to send all files at once.
My question is how to add functionality of 5MB total document per Document type.
For example : I can add many PDF file for Administrator Document type But total file save not more than 5MB than I can add more document for another Document type. And also in Upload function i know which file are associated with which document type
Hopes for your suggestion Thanks