我想使用强大的解析表单与多个文件上传,但不知何故结果只显示一个文件。下面是解析的代码,我直接复制从这里举例: https://github.com/felixge/node-formidable厉害只能处理一个文件?
var form = new formidable.IncomingForm();
form.multiples = true; // per their documents
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})); // files only contain one file,
// and files.length is undefined. It is not an array.
});
这里是我的HTML:
<FORM action="/file"
enctype="multipart/form-data"
method="post">
<br>
What is your name?
<INPUT type="text" name="kk1_submit-name"><BR>
What files are you sending?
<INPUT type="file" multiple="multiple" name="uploads"><BR>
<INPUT type="submit" value="Upload">
</FORM>
输出JSON对象只有一个文件对象,files.length是不确定的,即使我选择了5个文件上传。这个中间件已经过很好的测试,我想我一定在某个地方犯了错误。
我做错了什么?谢谢!
我明白了。那就是问题所在。 NPM多久更新一次资料库? –
“强大”的维护者决定何时发布该模块的新版本。 – bnuhero