multer nodejs express code example
Example 1: how to set file type and size in multer
var multer = require('multer')
var upload = multer().single('avatar')
app.post('/profile', function (req, res) {
upload(req, res, function (err) {
if (err instanceof multer.MulterError) {
} else if (err) {
}
})
})
Example 2: express multer
$ npm install --save multer
var express = require("express");
var multer = require('multer');
var upload = multer({dest:'uploads/'});
Example 3: multer()
var multer = require('multer');
var upload = multer({dest:'uploads/'});