我正在使用强大的包来上传文件。这是我的服务器端代码。
var formidable = require('formidable'),
http = require('http'),
util = require('util');
app.post('/admin/uploads', function(req, res) {
console.log(req.files, req.fields);//It prints
var form = new formidable.IncomingForm();
form.parse(req, function(err, fields, files) {
console.log("Inside form parse.");//its not printing
console.log(err, fields, files);//its not printing
});
form.on('file', function(name, file) {console.log('file='+file);});//its not printing
form.on('error', function(err) { console.log(err); });//its not printing
form.on('aborted', function() { console.log('Aborted'); });//its not printing
console.log(form);//it prints
});
上述代码中,form.parse()方法没有被调用,请给出解决方案。