I want use formidable with express in node.js to achieve upload image function,
what I do is :
app.configure(function () {
app.use(express.static(__dirname + "/media"));
app.use(express.bodyParser());
})
app.post('/upload', function (req, res) {
var form = new formidable.IncomingForm();
form.parse(req, function(err, fields, files){
console.log("log in parse");
console.log("fields type is " + typeof fields);
console.log("files type is " + typeof files);
console.log(files.image);
if (err) return res.send('You found error');
});
})
with this code, the image could upload successully, but the form.parse
function seems doesn't been invoked, cuz the log
doesn't been invoked
Why?What's wrong with my code?