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

157
Vistas
How te get an element from .fields

I am having trouble getting the property filename from the req.files that I get from the router. Here's what I get:

Image of the result of requiring req.files

And here's how I've been trying to get the filename of each (I am only using 2 pictures in this example but I could get more than two images so that's why I am iterating with the forEach)

let arrayImages = [];

if (req.files) {                                                      
  Array(req.files).forEach(image => {
    arrayImages.push(image[0].filename);
  })
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Hi everyone thanks for all the help, i finally figured it out!

let arrayImages = [];
for (const clave in req.files) {
    array = req.files[clave]
    arrayImages.push(`${array[0].filename}`);
}

that way i've got the fieldname of each element

about 4 years ago · Juan Pablo Isaza Denunciar

0

The root of your data from screen is an object.

So try to code like that:

let arrayImages = [];

if (req.files) {                                                      
  Object.values(req.files).forEach(arr => {
    arrayImages.push(arr[0].filename);
  })
}
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