Sha256: f9280ee8617c4cedaf6d6f4b44c4e0e0b6428c7a64ae3413a53836abb8f3e6d2
Contents?: true
Size: 960 Bytes
Versions: 17
Compression:
Stored size: 960 Bytes
Contents
var connect = require('../') , http = require('http'); // visit form.html var app = connect() .use(connect.static(__dirname + '/public')) .use(connect.bodyParser()) .use(form) .use(upload); function form(req, res, next){ if ('GET' != req.method) return next(); res.statusCode = 302; res.setHeader('Location', 'form.html'); res.end(); } function upload(req, res){ res.setHeader('Content-Type', 'text/html'); res.write('<p>thanks ' + req.body.name + '</p>'); res.write('<ul>'); if (Array.isArray(req.files.images)) { req.files.images.forEach(function(image){ var kb = image.size / 1024 | 0; res.write('<li>uploaded ' + image.name + ' ' + kb + 'kb</li>'); }); } else { var image = req.files.images; var kb = image.size / 1024 | 0; res.write('<li>uploaded ' + image.name + ' ' + kb + 'kb</li>'); } res.end('</ul>'); } http.Server(app).listen(3000); console.log('Server started on port 3000');
Version data entries
17 entries across 17 versions & 2 rubygems