I am working with Multer and Multer S3 to allow users to upload images on a Node project. I am wanting the user to be able to upload 3 images regardless of their size but no more. If a user tries to select say 6 images I get this error page:
Error: Unexpected field
at makeError
How would I change my code below to not allow a user to select/upload more than 3 images and/or handle the error in a better way.
Partial Code:
router.post("/", upload.array('image', 3), function(req, res, next){
var filepath = undefined;
var filepath2 = undefined;
var filepath3 = undefined;
if(req.files[0]) {
filepath = req.files[0].key;
}
if(req.files[1]) {
filepath2 = req.files[1].key;
}
if(req.files[2]) {
filepath3 = req.files[2].key;
}.....
via AndrewLeonardi
No comments:
Post a Comment