Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

urlencoded / multipart form parsing middleware for Connect

tree: 04a9838a90

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 support
Octocat-spinner-32 test
Octocat-spinner-32 .gitmodules
Octocat-spinner-32 History.md
Octocat-spinner-32 Makefile
Octocat-spinner-32 Readme.md
Octocat-spinner-32 docs.html
Octocat-spinner-32 index.js
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.onComplete = 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();
        }
    }
);
Something went wrong with that request. Please try again.