urlencoded / multipart form parsing middleware for Connect
Latest commit 6abfb69 Jul 28, 2010 @tj tj Release 0.1.2
Permalink
Failed to load latest commit information.
lib Removed require("connect/utils") Jul 28, 2010
support Added connect submodule for testing Jul 20, 2010
test Allow bodyDecoder / connect-form to coexist Jul 27, 2010
.gitmodules Added connect submodule for testing Jul 20, 2010
History.md Release 0.1.2 Jul 28, 2010
Makefile
Readme.md
index.html Release 0.1.0 Jul 14, 2010
index.js Added lib/connect-form.js Jul 27, 2010
package.json

Readme.md

Connect Form

Connect Form is a multipart / urlencoded form parsing middleware utilizing node-formidable behind the scenes.

Installation

Via git:

$ git clone git://github.com/visionmedia/connect-form.git ~/.node_libraries/connect-form

via npm:

$ npm install connect-form

Example

var form = require('connect-form');
var server = connect.createServer(
    form({ keepExtensions: true }),
    function(req, res, next){
        // Form was submitted
        if (req.form) {
            // Do something when parsing is finished
            // and respond, or respond immediately
            // and work with the files.
            req.form.complete(function(err, fields, files){
                res.writeHead(200, {});
                if (err) res.write(JSON.stringify(err.message));
                res.write(JSON.stringify(fields));
                res.write(JSON.stringify(files));
                res.end();
            });
        // Regular request, pass to next middleware
        } else {
            next();
        }
    }
);