Skip to content

Instantly share code, notes, and snippets.

@anttti
Last active December 31, 2015 03:19
Show Gist options
  • Save anttti/7926388 to your computer and use it in GitHub Desktop.
Save anttti/7926388 to your computer and use it in GitHub Desktop.
const
fs = require('fs'),
path = require('path'),
express = require('express'),
app = express();
app.use(express.bodyParser({ uploadDir:'./uploads' }));
app.post('/', function(req, res) {
var targetPath = path.resolve('./uploads/' + req.files.uploadedFile.name);
fs.rename(req.files.uploadedFile.path, targetPath, function(err) {
if (err) throw err;
res.end('Upload completed!');
});
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment