Conect bodyParser Middleware

20 views
Skip to first unread message

Ishan Gupta

unread,
Mar 22, 2015, 11:33:44 AM3/22/15
to nod...@googlegroups.com
Hi,

I am trying to upload an image using bodyparser middleware in Connect.
But when i try to print req.files, it is showing undefined.

Here is my server code:-

conn.use(connect.bodyParser());
conn.use(function(req,res){
                console.log(req.headers);
                console.log(req.body);
                console.log(req.files);
                res.end();
                });
conn.listen(3000);

Here is the curl command:-
curl -F "image=@World_Challenge.jpg" -F "name=ishan" http://localhost:3000

Thanks

Aria Stewart

unread,
Mar 22, 2015, 11:55:41 AM3/22/15
to nod...@googlegroups.com


On Sunday, March 22, 2015 at 11:33:44 AM UTC-4, Ishan Gupta wrote:
Hi,

I am trying to upload an image using bodyparser middleware in Connect.
But when i try to print req.files, it is showing undefined.


You will need multipart parsing middleware, not just bodyparser. Perhaps something like formidable, or multiparty and connect-multiparty, or busboy and connect-busboy, or multer.

Aria
Reply all
Reply to author
Forward
0 new messages