javascript - POST Request Issue in ExpressJS -



javascript - POST Request Issue in ExpressJS -

i'm working nodejs , i'm working on letting users upload files. right though i'm having lot of problem trying simple post request.

over in index.ejs file have code creates form , sends post request:

<div id="uploaddiv">upload things here<br> <form action="/upload" enctype="multipart/form-data" method="post"> <input type="text" name="title"><br> <input type="file" name="upload" multiple="multiple"><br> <input type="submit" value="upload"> </form> </div>

then in server.js, have code handles uploading.

var server = express.createserver(); //bunch of stuff left out server.get('/upload', function(req, res) { console.log("uploading!"); if (req.method.tolowercase() == 'post') { res.write('lol'); } });

my problem navigating straight localhost/upload console.log properly, clicking on button gives me error "cannot post /upload".

thanks!

server.get means handle http get. want server.post. fyi "cannot xxx /uri" error express responds when no active route matches request , no 404 error handler has been configured.

javascript node.js express

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -