Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add support for input[type="file"][multiple] uploads

  • Loading branch information...
commit 812d491a12f0504ffd86b509c43fccb0d069c276 1 parent d671bef
@jankuca authored
Showing with 19 additions and 4 deletions.
  1. +18 −3 lib/ServerRequest.js
  2. +1 −1  package.json
View
21 lib/ServerRequest.js
@@ -25,12 +25,27 @@ var ServerRequest = function (req) {
this.cookies = cookies;
if (req.headers['content-type']) {
+ self.body = {};
+ self.files = {};
+
var form = new IncomingForm();
- form.parse(req, function (err, fields, files) {
- self.body = fields;
- self.files = files;
+ form.on('field', function (key, value) {
+ self.body[key] = value;
+ });
+ form.on('file', function (key, value) {
+ var old = self.files[key];
+ if (Array.isArray(old)) {
+ old.push(value);
+ } else if (old) {
+ self.files[key] = [ old, value ];
+ } else {
+ self.files[key] = value;
+ }
+ });
+ form.once('end', function () {
self.emit('body');
});
+ form.parse(req);
} else {
var data;
var body = '';
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "darkside",
- "version": "1.0.12",
+ "version": "1.0.12b",
"description": "Web App Framework (HTTP, WebSockets, MVC, DI)",
"contributors": [
{
Please sign in to comment.
Something went wrong with that request. Please try again.