Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
remove / add files dynamically to upload field

I have this input field for file upload:

<input onchange="getFiles()" type="file" name='files[]' id="customFile" multiple />

On click I can seelct multiple files for upload. Onchange the function getFiles starts:

function getFiles() {
   console.log( $('#customFile').get(0).files )
}

which shows me this result:

enter image description here

This are my two example files. But If I forgot a file for upload I would be able to add this file with a new upload process. Problem is, if I click again on my upload field and select the forgotten file, it will override the other 2 selected files bevor.

In my "FileList" will only be the last selected. Is there a way to add one file instead to select all 3 files again for upload?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You might want to save previously uploaded files in local array and push to it inside "getFiles" event handler. Something like this:

const uploadedFiles = [];
function getFiles() {
  uploadedFiles.push(...$('#customFile').get(0).files);
}

It might also be a good idea to refer to file input using "this" con

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda