How to upload a single Image using Multer when req. file is always empty when testing with Postman?

I am trying to upload an image using multer and this is the code that I am just testing:

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.


  [1]: https://i.stack.imgur.com/CS0CK.png


from Recent Questions - Stack Overflow https://ift.tt/3sNKuKK
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation