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

127
Vistas
How to get files count if the input file type was in a modal?

I have an input type file but it's in a modal, how to get its files count? I have tried below, but I can't get the value, what did I do wrong?

for (var index = 0; index < document.getElementById('supporting_files').files.length; 
  index++) {
     params.append("supporting_files", 
     document.getElementById('supporting_files').files[index]);
}

snippet

<div class="modal-dialog modal-dialog-centered modal-dialog- scrollable">
    <div class="modal-content">
    <div class="modal-body">
    <form id="form-pickupModal" method="post" autocomplete="off" 
       novalidate="novalidate">
        <div class="row">
           <div class="col">
              <div class="form-group">
                <label class="form-label" for="supporting_files">Supporting files</label>
                <input class="form-control" id="supporting_files" name="supporting_files" type="file" accept=".jpg,.jpeg,.png,.xlsx,.xls,.doc,.docx,.pdf" value="" multiple>
             </div>
          </div>
         </div>
      </div>
   </div>
</div>

As you see from the above snippet, it's a modal with an input file type there, I don't have an idea on how to get it's value.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use length property of FileList to get number of files selected. and use item method to get particular file via index.

function grabFiles() {
    console.log('Selected few files');
    const files = document.getElementById('all_files').files;
    //Note that this files variable is of type FileList and it has a property length
    console.log('Number of file selected is: ', files.length);
    for (let i = 0; i < files.length; i++) {
        console.log(files.item(i));
    }
}
<input type="file" id="all_files" multiple onchange="grabFiles()" />

about 4 years ago · Santiago Trujillo 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