I have a file input and I am trying to save the selected file into an object of all the selected files so in the future I can submit them. The problem is that whenever a new file is chosen in the file input, the other files are deleted in the object. I tried copying the file, or doing deep copy but it doesn't work, or something like this:
var filesObj = {}
var i = 0;
var fileInput = document.getElementById('fileInput')
fileInput.addEventListener("change", function(ev){
let file = fileInput.files[0];
let blob = new Blob([file], {type: file.type});
let fileCopy = new File([file], file.name, { type: file.type, lastModified: file.lastModified });
filesObj[i] = fileCopy;
i++
});
Thanks in advance