Reputation: 31
Multer for multiple fields.
I want to upload images via the file field (one image), as well as upload an image via "Summernote".
This is all one controller. How to implement work with multer?
upload.single ()
, upload.array ()
?
How to implement correctly?
When I upload via "Summernote" I get the error:
MulterError: Unexpected field", because there is a conflict with the fields.
At the momemt:
router.post('/create', upload.single('cover'), post.savePost)
Upvotes: 1
Views: 1673
Reputation: 31
I solved this issue:
router.post('/create', upload.fields([{
name: 'cover',
maxCount: 1,
}, {
name: 'files'
}]), post.savePost)
Upvotes: 2