解决方法
刚刚回答了关于多部分的
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,所以你是正确的避免它,但多方似乎为我解决了类似的问题.
原文地址:https://www.jb51.cc/js/157678.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。