node express + formidable + form with multipart/fo

2019-08-03 21:46发布

问题:

I'm using mean stack

and formidable to upload file

the form has a multipart/form-data attribute

exports.create = function(req, res) {
    console.log(req.body);
}

but the rq.body is empty. How can I get it ?

回答1:

If you are using formidable for multipart upload, you can get req.body fields in

form.parse(req, function(err, fields, files) 

fields.item