I'm new to NodeJS and I tried this to post images through postman. But I can't figure out where am I lacking?
The postman parameters :
NodeJS Code
Now to access these values in my NodeJS, I'm currently doing this :
var express = require('express');
var bodyParser = require('body-parser');
const router = express.Router();
router.use(bodyParser.json());
router.post('/postData/uploadStory', function(req, res) {
console.log(req.files);
console.log(req.body);
res.json("Hi");
})
How can I get access to the image and the key-value?
Also looked at express-fileupload node-module for doing this work for me.
- Created a simple ejs with
input name=foo type=file
- tried to access it in the server.js file as
console.log(req.files)
.
Didn't work.
Am I missing something? Please help. Thanks.