How to upload a file along with json data?

There is a form
Name
Date
Password
Avatar

server.js
fileUpload = require('express-fileupload');
app.use( fileUpload() );
app.use( bodyParser.json() );
app.use( bodyParser.urlencoded({ extended: false }) );
....

Further, the router
publicRouter.put('/finishUserRegistration', ctrlAuth.finishUserRegistration);


And the handler itself
module.exports.finishUserRegistration = function(req, res) {
console.log(req.files)
};

req.files gives undefined. What's the problem?
March 20th 20 at 11:30
0 answer

Find more questions by tags Node.jsExpress.js