Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

404
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda