Advertisement
framp

Uploading a file with flatiron

Aug 5th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var connect = require('connect'),
  2.     union = require('union');
  3.  
  4. var server = union.createServer({
  5.   buffer: false,
  6.   before: [
  7.     connect.bodyParser(),
  8.     function(req, res) {
  9.         if (req.method==='POST'){
  10.             console.log(req.files);
  11.         }else{
  12.             res.end('<form method="post" enctype="multipart/form-data">' +
  13.                         '<input type="file" name="file" />' +
  14.                         '<input type="submit" value="Upload" />' +
  15.                         '</form>');
  16.         }
  17.     },
  18.   ]
  19. }).listen(8000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement