How to store a file with file extension with multer?

I have a workaround for the adding proper extension of files. If you use path node module var multer = require(‘multer’); var path = require(‘path’) var storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, ‘uploads/’) }, filename: function (req, file, cb) { cb(null, Date.now() + path.extname(file.originalname)) //Appending extension } }) var upload = … Read more

Cannot app.use(multer). “requires middleware function” error

You need to use app.use(multer({dest:’./uploads/’})) in the form of one of these: app.use(multer({dest:’./uploads/’}).single(…)); app.use(multer({dest:’./uploads/’}).array(…)); app.use(multer({dest:’./uploads/’}).fields(…)); ie: app.use(multer({dest:’./uploads/’}).single(‘photo’)); And be sure to have something like: <form action=”/postPhotos” enctype=”multipart/form-data” method=”post”> <input type=”file” name=”photo”> <input type=”submit” value=”Upload photo”> </form> In your html.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)