Skip to content

Commit

Permalink
File upload name related changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jalpesh vadgama authored and jalpesh vadgama committed Jan 24, 2017
1 parent 178daa4 commit 68a598b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions routes/index.js
Expand Up @@ -3,14 +3,23 @@ var router = express.Router();

//multer object creation
var multer = require('multer')
var upload = multer({ dest: 'public/uploads/' })
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'public/uploads/')
},
filename: function (req, file, cb) {
cb(null, file.originalname)
}
})

var upload = multer({ storage: storage })

/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});

router.post('/', upload.any(),function(req, res) {
router.post('/', upload.single('imageupload'),function(req, res) {
res.send("File upload sucessfully.");
});

Expand Down

0 comments on commit 68a598b

Please sign in to comment.