MulterError:意外字段
我收到上述错误。我搜索了stackoverflow,发现html中type =“ file”的name属性应与服务器代码中的upload.single('name')相匹配。在我的代码中都是mamtch,但是我遇到了相同的错误。任何人都可以提出我在做什么错。谢谢
Models.js
imageTwo: String,
imageIdTwo: String
form.ejs ```
<div class="form-group">
<label for="image2">Image</label>
<input type="file" id="imageTwo" name="imageTwo" accept="image/*" required>
</div>
router.post(“ /”,middleware.isLoggedIn,middleware.canComment,upload.single('imageTwo'),功能(要求,res){
cloudinary.v2.uploader.upload(req.file.path, function(err, result) {
// add cloudinary url for the image to the campground object under image property
// req.body.campground.image = result.secure_url;
if(err) { req.flash('error', err.message); return res.redirect('back'); }
//used
req.body.usedCar.imageTwo = result.secure_url;
req.body.usedCar.imageIdTwo = result.public_id;
```
应该上传