diff --git a/lib/index.js b/lib/index.js index f4eafdb..3d6bfbd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -50,7 +50,7 @@ module.exports = function(options) { console.log('filename yo', filename); } - return req.files[fieldname] = { + var newFile = { name: filename, data: buf, encoding: encoding, @@ -67,6 +67,15 @@ module.exports = function(options) { }); } }; + + if (!req.files.hasOwnProperty(fieldname)) { + req.files[fieldname] = newFile; + } else { + if (req.files[fieldname] instanceof Array) + req.files[fieldname].push(newFile); + else + req.files[fieldname] = [req.files[fieldname], newFile]; + } }); });