Почему multer после отправки формы всегда возвращает значение - не определено?
app.js
app.use('/post', routePost);
Контроллер:
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './pubic/uploads')
},
filename: function (req, file, cb) {
cb(null, file.fieldname + '-' + Date.now())
}
router.post('/create', upload.single('cover'), (req, res) => {
console.log(req.file)
})
HTML:
<form action="/post/create" method="POST" enctype="multipart/form-data">
<input id="cover" name="cover" type="file" />
<button type="submit">Save</button>
</form>