cannot handle image uploads using expressjs

I am using express v2.5.8. I am uploading a file from a multipart form where the file input in the form is classified as a file:

Form: enctype="multipart/form-data"

Element: type='file'

Within the server side app, I have set the following: app.use(express.bodyParser({uploadDir:'./files/ph'})), //valid directory and no write issues

I have also required the 'fs' module.

Within the form handling route, I can see req.body but when I try to access req.files, it seems to be undefined & when I check the req.is('image'), the result is false.

Any suggestions on handling image uploads from a html form handled via express would be appreciated.

Thanks in advance.

Answers


I switched to node-formidable and it works for me - I will check above logic again once I use express v3.0/connect v2.0 (it seems like req.files for multipart data is available in express 3.0/connect 2.0 though I am not entirely certain so please do your own due diligence about it).


Need Your Help

What is an alternative to eval in this situation?

python django django-views

I am pretty bad at stating my problem clearly. Sorry.

Detecting if client's browser has Cookies Turned Off

php web-services cookies

I want to check if the user of my website is allowing cookies or not.