简体   繁体   中英

Multer [NodeJS] for multiple fields

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)

I solved this issue:

router.post('/create', upload.fields([{
    name: 'cover',
    maxCount: 1,
}, {
    name: 'files'
}]), post.savePost)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM