解决方法
刚刚回答了关于多部分的
similar question.我会推荐multiparty:
你试过node-multiparty了吗?以下是自述文件中的示例用法:
var multiparty = require('multiparty'),http = require('http'),util = require('util') http.createServer(function(req,res) { if (req.url === '/upload' && req.method === 'POST') { // parse a file upload var form = new multiparty.Form(); form.parse(req,function(err,fields,files) { res.writeHead(200,{'content-type': 'text/plain'}); res.write('received upload:\n\n'); res.end(util.inspect({fields: fields,files: files})); }); return; } // show a file upload form res.writeHead(200,{'content-type': 'text/html'}); res.end( '<form action="/upload" enctype="multipart/form-data" method="post">'+ '<input type="text" name="title"><br>'+ '<input type="file" name="upload" multiple="multiple"><br>'+ '<input type="submit" value="Upload">'+ '</form>' ); }).listen(8080);
作者(Andrew Kelley)recommends避免使用bodyParser,所以你是正确的避免它,但多方似乎为我解决了类似的问题.