Node.js http file upload

Description

Node.js http file upload

var fs = require('fs');
var http = require('http');

http.createServer(function(req, res) {
  var newFile = fs.createWriteStream("uploaded.txt");
  req.pipe(newFile);/*from  ww  w .j  a v a 2 s  . com*/

  req.on('end', function() {
    res.end('uploaded!');
  });
}).listen(1337);

console.log('Server running at http://localhost:1337');



PreviousNext

Related