A
A
Adel Khalitov2019-05-02 15:11:52
Node.js
Adel Khalitov, 2019-05-02 15:11:52

How to upload files 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 }) );
....

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

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

req.files returns undefined. What is the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question