Working with expressjs for about a month by now I have stumbled across the problem of file uploads. Despite consulting Google & various blogs I have failed finding an answer to the following three questions:
What do I have to do / what settings for bodyParser do I have to choose in order to:
Make sure there was indeed a file uploaded (currently, when submitting the form without choosing a file an empty file gets created).
Where can I specify a value for the maxium size a file is allowed to have?
How can I omit the renaming of the file?
Currently I am including bodyParser in my express (v. 3.0.0) app with the following option:
{keepExtensions: true, uploadDir: __dirname + '/public/uploads'}
About your concern
After long search I found a great solution
First you need to install node-formidable
Then after including the library, to check if file uploaded in the first place
And about the size you can check this.
Best regards.
Abdulaziz Noor
I recently ran into a similar problem. for Question #2, check http://www.senchalabs.org/connect/middleware-limit.html
app.use(express.limit('4M')); // in your app.configure()