简体   繁体   中英

how to configure formidable in app.use express?

this is a simple question... how can i use formidable instead bodyparser()...

how to configure in app.use

app.configure(function(){
app.set('port', process.env.PORT || 9000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view options',{layout:false});
app.use(express.favicon());
app.use(express.bodyParser();
app.use(express.cookieParser('blocksecretpass'));
app.use(express.session());

im using expressjs 3 rc4 nodejs 0.8 formidable 1.0.11 on windows 7 64-bit why i need?? because i have to post some files and bodyparser() shutdown my node app this is the error

https://github.com/felixge/node-formidable/issues/34
https://github.com/felixge/node-formidable/issues/130

the solution to issues is app.use express.bodyparser before any other middleware that try to use async calls

tnx all

Don't use .bodyParser() , it is being deprecated.

Use

app.use(express.json());
app.use(express.urlencoded());

Consider using alternatives: http://www.senchalabs.org/connect/multipart.html . Formidable is one of them.

You're already using formidable. Express is based on connect and the multipart middleware is based on formidable. Have a look at the express example to learn how to upload files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM