Skip to content

Instantly share code, notes, and snippets.

@arifsetiawan
Created November 28, 2011 17:27
Show Gist options
  • Save arifsetiawan/1401194 to your computer and use it in GitHub Desktop.
Save arifsetiawan/1401194 to your computer and use it in GitHub Desktop.
upload form
var express = require('express');
// express setup
var app = express.createServer();
app.use(express.bodyParser());
app.get('/', function(req, res){
res.writeHead(200, {'content-type': 'text/html'});
res.end(
'<form action="/upload" enctype="multipart/form-data" method="post">'+
'<input type="text" name="title"><br>'+
'<input type="file" name="upload" multiple="multiple"><br>'+
'<input type="submit" value="Upload">'+
'</form>'
);
});
app.post('/upload', function(req, res){
console.log('upload ' + JSON.stringify(req.body));
res.send('post photo');
});
app.listen(process.env.PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment