I want to upload a file with a form like this (JADE) :
form(action="/file-upload", name="upload", method="post", enctype="multipart/form-data")
input(type="file", name="theFile")
input(type="submit", name="Upload")
this is my app.js :
app.use(express.methodOverride());
app.use(express.multipart());
app.use(express.bodyParser());
and this is how I handle the requests:
app.post('/file-upload',function(req,res){
console.log('FIRST TEST: ' + JSON.stringify(req.files));
console.log('second TEST: ' +req.files.theFile.name);
});
and this is my Node.js Console :
FIRST TEST: undefined
TypeError: Cannot Read Property 'theFile' of undefined....etc....
oh and by the way there is a warning from Connect module :
connect.limit() will be removed in connect 3.0
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
What am I do wrong here ? i have follow advise from here, here, here with nothing works. Thanks for help.....
UPDATE: i just added LOGGER to my apps with result, so it's seems that i got the request:
127.0.0.1 - - [Wed, 19 Feb 2014 11:02:11 GMT] "POST /file-upload HTTP/1.1" 500 -
"http://localhost:3000/admin/news-add" "Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"