Skip to content

Instantly share code, notes, and snippets.

@pavinduLakshan
Created June 22, 2020 12:53
Show Gist options
  • Save pavinduLakshan/a25ac94c5b3d3d381077cd309849cc22 to your computer and use it in GitHub Desktop.
Save pavinduLakshan/a25ac94c5b3d3d381077cd309849cc22 to your computer and use it in GitHub Desktop.
const multer = require('multer');
// Create a directory '/uploads' in your project root, Uploaded images are stored there.
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'uploads')
},
filename: function (req, file, cb) {
cb(null, Date.now() + '-' +file.originalname )
}
})
var upload = multer({ storage : storage }).array('file');
module.exports = upload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment