Tuesday, 12 November 2019

Node.js - Formidable for multipart/form-data upload is not working

const express = require('express'); const app = express(); const formidable = require('formidable'); app.post('/upload', (req, res) => { let form = new formidable.IncomingForm(); form.parse(req, (err, fields, files) => { if(err) { console.log(err); return res.send(err); } else { console.log(fields); console.log(files); return res.send(fields); } }); }); app.listen(8080, () => console.log('App is running'); The following code throws the error after a long time. The error is -Error: Request aborted Request is sent through Postman with form-data Body, fields are description(text) and input(file)

Submitted November 12, 2019 at 05:42PM by nk1012

No comments:

Post a Comment