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?