T
T
the5x2019-03-15 21:40:49
JavaScript
the5x, 2019-03-15 21:40:49

Why is multer undefined?

Why is multer undefined?

var storage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, './pubic/uploads')
    },
    filename: function (req, file, cb) {
        cb(null, file.fieldname + '-' + Date.now())
    }
})

var upload = multer({
    storage: storage
});

router.post('/create', upload.single('cover'), (req, res) => {
    console.log(req.file)
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artur Berdyev, 2019-03-16
@lordgreem

Have you linked the library to the file?
const multer = require('multer');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question