About your concern
Make sure that the file was actually uploaded (currently, when you submit a form without selecting a file, an empty file is created).
After a long search I found a great solution
First you need to install node-formidable
Then after turning on the library, to check if the file is loaded first
var form = new formidable.IncomingForm(); form.parse(req, function(err, fields, files) { if (Object.keys(files).length !== 0) { console.log("File is exist") } else { console.log("File is not exist") } });
And about the size you can check.
form.maxFieldsSize = 2 * 1024 * 1024;
Sincerely.
Abdulaziz Nur
source share