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

100
Views
How to upload files in separate folder from req.files in express multer in one request

I am working on a project that accepts 3 .jpg files from the request. I want 2 of them to be uploaded in a separate folder and the other file in a separate folder. If I use

upload.fields([{ name: 'nid_front', maxCount: 1 }, { name: 'nid_back', maxCount: 1 }])

it gives me an error

{
  err: MulterError: Unexpected field
      at wrappedFileFilter (D:\ontheway\node_modules\multer\index.js:40:19)
      at Busboy.<anonymous> (D:\ontheway\node_modules\multer\lib\make-middleware.js:114:7)
      at Busboy.emit (events.js:400:28)
      at Busboy.emit (D:\ontheway\node_modules\busboy\lib\main.js:38:33)
      at PartStream.<anonymous> (D:\ontheway\node_modules\busboy\lib\types\multipart.js:213:13)
      at PartStream.emit (events.js:400:28)
      at HeaderParser.<anonymous> (D:\ontheway\node_modules\dicer\lib\Dicer.js:51:16)
      at HeaderParser.emit (events.js:400:28)
      at HeaderParser._finish (D:\ontheway\node_modules\dicer\lib\HeaderParser.js:68:8)
      at SBMH.<anonymous> (D:\ontheway\node_modules\dicer\lib\HeaderParser.js:40:12) {
    code: 'LIMIT_UNEXPECTED_FILE',
    field: 'photo',
    storageErrors: []
  }
}

I want two of those my files to be uploaded separately and another field with the name photo to be uploaded in a separate folder.

How should I do that?

about 4 years ago · Juan Pablo Isaza
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!