Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Docs

  • Loading branch information...
commit 7ba9a2eb248057a31764bd050fe3f83d866217e1 1 parent 2dd93e3
@tj tj authored
Showing with 52 additions and 0 deletions.
  1. +28 −0 Readme.md
  2. +24 −0 index.js
View
28 Readme.md
@@ -0,0 +1,28 @@
+
+# Connect Form
+
+Connect Form is a multipart / urlencoded form parsing middleware utilizing [node-formidable](http://github.com/felixge/node-formidable) behind the scenes.
+
+## Examples
+
+ var server = connect.createServer(
+ multipart({ 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();
+ }
+ }
+ );
View
24 index.js
@@ -21,6 +21,30 @@ var utils = require('connect/utils'),
* - `uploadDir` Directory to save uploads. Defaults to "/tmp"
* - `keepExtensions` Include original extensions. Defaults to `false`
*
+ * Examples:
+ *
+ * var server = connect.createServer(
+ * multipart({ 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();
+ * }
+ * }
+ * );
+ *
* @param {Object} options
* @return {Function}
* @api public
Please sign in to comment.
Something went wrong with that request. Please try again.