我正在尝试使用multer上传图像,这是我正在使用Postman测试的代码:
const upload = multer({ dest: 'uploads/' })
router.post('/uploadImage', upload.single('file'), (req,res)=>{
console.log("Entering uploadImage Post")
console.log("req.file contains:",req.file)
res.status(204).end()
});
[nodemon] starting `node app.js`
Servidor corriendo en puerto 5000
Connected to mongoDB...
Entering uploadImage Post
req.file contains: undefined```
This is the testing that I am doing in Postman:
[![enter image description here][1]][1]
So my problem is that the req.file is undefined , and I am not getting the images. Please check the following image
[1]: https://i.stack.imgur.com/CS0CK.png
我必须清除标题,所以我可以获得req.file
,
有了这个改变,它工作了。