Last active
August 19, 2019 13:21
-
-
Save NikhilNanjappa-zz/b6a1733c77a9fba0d375898ace01c1a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const formidable = require('formidable'); | |
module.exports = function (req, res, next) { | |
const formData = new formidable.IncomingForm(); | |
formData | |
.parse(req, (err, fields, files) => { | |
if (err) { | |
next(err); | |
} else { | |
req.body = fields; | |
req.files = files; | |
next(); | |
} | |
}) | |
.on('error', err => { | |
next(err); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment