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.
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).