How to get other type fields when Multipart/form-data in expresses
You could use the multiparty module as follows
var multiparty = require('multiparty');exports.parseForm = function (req, res) { var form = new multiparty.Form(); form.parse(req, function(err, fields, files) { //here you can read the appropriate fields/files });};
Also be sure you are setting the enctype
correctly in your html
<form role='form' method='post' enctype="multipart/form-data">
When I used this it was to submit multiple text fields, and a single image file, via the HTML form. Then in my parseForm
function I would bundle these into a single object to be saved to mongo as follows
form.parse(req, function(err, fields, files) { var temp = fields; temp.image = {}; temp.image.data = fs.readFileSync(files.image[0].path); temp.image.contentType = 'image'; var product = new Product(temp); product.save(); res.redirect('/');});