'how can I get a filename of images using muter upload.fields

please help me out, I want to save the filename of the image in the database.

how can I get the filename of the image using multer upload.fields

enter image description here

enter image description here



Solution 1:[1]

You can iterate the object req.files and then again the result e get the filenames.

req.files.forEach(file => {
  file.forEach(item => {
    console.log("Filename", item.filename)
  })
})

You can save it directly or append it to a list and then save them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shura16