Skip to content

Commit

Permalink
Merge pull request #18 from flplv/fix-multiple
Browse files Browse the repository at this point in the history
Fix input fields with multiple enabled:
  • Loading branch information
richardgirges authored Feb 10, 2017
2 parents 994e1cb + ec6270d commit d9425c0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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];
}
});
});

Expand Down

0 comments on commit d9425c0

Please sign in to comment.