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

158
Views
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 answers
Answer question

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 Report

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 Report
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!