Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var express = require('express');
var app = express();
var path = require('path');
var http = require('http');
var multer = require('multer');
var storage = multer.diskStorage({
destination: './uploads/',
filename: function (req, file, cb) {
cb(null, file.originalname.replace(path.extname(file.originalname), "") + '-' + Date.now() + path.extname(file.originalname))
}
})
var upload = multer({ storage: storage })
app.use(express.static(path.join(__dirname, 'public')));
app.set('port', process.env.PORT || 3000);
app.post('/savedata', upload.single('file'), function(req,res,next){
console.log('Uploade Successful ', req.file, req.body);
});
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.