Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

393
Views
Deleting a file, deletes a copy of the file JS

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!