强大的只能处理一个文件?

我试图用强大的parsing表单与多个file upload,但不知何故结果只显示一个文件。 这里是我从这里直接复制的parsing代码: 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是未定义的,即使我select了5个file upload。 这个中间件经过了很好的testing,我想我肯定是在某个地方犯了一个错误。

我做错了什么? 谢谢!

formidable模块开始支持一个月前上传多个文件。 但npmjs.orgformidable模块已经在11个月前更新了。 所以你需要手动安装最新的formidable

 git clone git://github.com/felixge/node-formidable.git node_modules/formidable 

现在再次运行应用程序,你应该得到正确的输出:

 received upload: { fields: { title: '' }, files: { upload: [ [Object], [Object] ] } } 

我切换到node-multiparty,一个窗体parsing器从强大的。 上传的文件数量是正确的。 所以也许这是一个强大的bug。 使用节点多方可以节省您一些时间。

在这里输入图像说明

自写作以来,“可畏”图书馆发生了翻天覆地的变化。 您现在必须显式设置IncomingForm对象的一些参数,最显着的是:

  • 倍数:真

如果你想绕过文件大小:

  • maxFileSize:(以字节为单位(不是maxFieldsSize))

这使您可以正确使用最新版本的强大