Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 39 lines (30 sloc) 1.112 kb
7ba9a2e @tj Docs
tj authored
1
2 # Connect Form
3
4 Connect Form is a multipart / urlencoded form parsing middleware utilizing [node-formidable](http://github.com/felixge/node-formidable) behind the scenes.
5
04a9838 @tj Install docs
tj authored
6 ## Installation
7
8 Via git:
9
10 $ git clone git://github.com/visionmedia/connect-form.git ~/.node_libraries/connect-form
11
12 via npm:
13
14 $ npm install connect-form
15
16 ## Example
7ba9a2e @tj Docs
tj authored
17
bd1a447 @tj More docs
tj authored
18 var form = require('connect-form');
7ba9a2e @tj Docs
tj authored
19 var server = connect.createServer(
bd1a447 @tj More docs
tj authored
20 form({ keepExtensions: true }),
7ba9a2e @tj Docs
tj authored
21 function(req, res, next){
22 // Form was submitted
23 if (req.form) {
24 // Do something when parsing is finished
25 // and respond, or respond immediately
26 // and work with the files.
8a1f77c @tj Changed api, use form.complete(function(){}) instead of form.onComple…
tj authored
27 req.form.complete(function(err, fields, files){
7ba9a2e @tj Docs
tj authored
28 res.writeHead(200, {});
29 if (err) res.write(JSON.stringify(err.message));
30 res.write(JSON.stringify(fields));
31 res.write(JSON.stringify(files));
32 res.end();
8a1f77c @tj Changed api, use form.complete(function(){}) instead of form.onComple…
tj authored
33 });
7ba9a2e @tj Docs
tj authored
34 // Regular request, pass to next middleware
35 } else {
36 next();
37 }
38 }
39 );
Something went wrong with that request. Please try again.