Quote:
function uploadFile() {
var file = _("file").files[0];
var formdata = new FormData();
formdata.append("file", file);
Your
uploadFile
function explicitly only sends the first file from the first input. If you want to upload files from multiple inputs, then you need to append each of them to the
FormData
object:
var formdata = new FormData();
var file = _("file");
for (var i = 0; i < file.files.length; i++) {
formdata.append("file", file.files[i]);
}
file = _("file1");
for (var i = 0; i < file.files.length; i++) {
formdata.append("file1", file.files[i]);
}
file = _("file2");
for (var i = 0; i < file.files.length; i++) {
formdata.append("file2", file.files[i]);
}
...
But the obvious question is why you need five separate file input which accept a single file each, rather than a single file input with the
multiple
attribute applied:
multiple - <input type="file"> - HTML: HyperText Markup Language | MDN[
^]