What can I do to store files in a local folder or database?
const multer = require('multer');
let storage = multer.diskStorage({
destination: '/public/my-uploads',
filename: function (req, file, cb) {
cb(null, file.fieldname + '-' + Date.now())
}
});
Use this file name instead of that if you are working on Windows OS, Your code is perfectly working on MAcOS
filename: (req, file, cb) => {
cb(
null,
new Date().toISOString().replace(/:/g, "-") + "-" + file.originalname
);
Hope it works for you...