Skip to content

Instantly share code, notes, and snippets.

@imamabdulazis
Last active August 4, 2020 16:11
Show Gist options
  • Select an option

  • Save imamabdulazis/33a656ce3b7839168d72f6f3aa119563 to your computer and use it in GitHub Desktop.

Select an option

Save imamabdulazis/33a656ce3b7839168d72f6f3aa119563 to your computer and use it in GitHub Desktop.
SDF
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads/');
},
filename: function (req, file, cb) {
console.log("FILE :", file)
cb(null, file.originalname);
}
})
const fileFilter = (req, file, cb) => {
if (file.mimetype === 'image/jpeg' || file.mimetype === 'image/png') {
cb(null, true);
} else {
cb(null, false);
}
}
const upload = multer({
storage: storage,
// limits: {
// fileSize: 1024 * 1024 * 5
// },
// fileFilter: fileFilter
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment