1var multer = require('multer')
2var upload = multer().single('avatar')
3
4app.post('/profile', function (req, res) {
5 upload(req, res, function (err) {
6 if (err instanceof multer.MulterError) {
7 // A Multer error occurred when uploading.
8 } else if (err) {
9 // An unknown error occurred when uploading.
10 }
11
12 // Everything went fine.
13 })
14})
15