Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit upload file size in express.js

i got this error says

error:request entity too large 

when uploading a video about 30MB,

here is the setting code

app.use(express.bodyParser({
    uploadDir:'./Temp',
    maxFieldsSize:'2 * 1024 * 1024 * 1024 ',
}));

am not sure how to set the maxFieldsSize property, need some help!!!

like image 456
paynestrike Avatar asked Nov 14 '12 06:11

paynestrike


1 Answers

Express uses connect middleware, you can specify the file upload size by using the following

app.use(express.limit('4M'));

Connect Limit middleware

like image 187
Sdedelbrock Avatar answered Oct 21 '22 14:10

Sdedelbrock