如何在需要时使用Multer上传单个图像.文件总是空的时候测试邮差?



我正在尝试使用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

有了这个改变,它工作了。

最新更新