I try to create a Uploadform with 2 Functions:
- preview images before upload | Done by this Thread: Adding multiple images with preview
- Show multiple input fields for each upload file. and send them in req.files
i have no clue how to archive this 🙁
$(document).ready(function () {
$('.uploadSubmit').on('click', function () {
var selected = [];
$('.dt-checkboxes:checked').each(function (t, d) {
selected.push(d.parentElement.nextElementSibling.nextElementSibling.innerHTML);
});
$('#mailgroupIDS').val(selected);
});
let imagesPreview = function (input, placeToInsertImagePreview) {
if (input.files) {
let filesAmount = input.files.length;
for (i = 0; i < filesAmount; i++) {
let reader = new FileReader();
reader.onload = function (event) {
$($.parseHTML("<img>")).attr("src", event.target.result).appendTo(placeToInsertImagePreview);
};
reader.readAsDataURL(input.files[i]);
}
}
};
$("#_uploadFiles").on("change", function () {
$("div.preview-images").html("");
imagesPreview(this, "div.preview-images");
});
});