This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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