var storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, 'upload1/') }, filename: function (req, file, cb) { var singfileArray = file.originalname.split('.'); var fileExtension = singfileArray[singfileArray.length - 1]; cb(null, singfileArray[0] + '-' + Date.now() + "." + fileExtension); console.log(file); } }) var upload = multer({ storage: storage })
router.post('/savedata', upload.single('logo'), function (req, res, next) { res.json({ name: req.body.name, age: 10, range: [1, 2, 3, 4, 5, 6, 7] }); });