How to limit the file size when uploading with multer?
问题 I'm making a simple file upload system with multer: var maxSize = 1 * 1000 * 1000; var storage = multer.diskStorage({ destination: function (req, file, callback) { callback(null, 'public/upload'); }, filename: function (req, file, callback) { callback(null, file.originalname); }, onFileUploadStart: function(file, req, res){ if(req.files.file.length > maxSize) { return false; } } }); var upload = multer({ storage : storage}).single('bestand'); router.post('/upload',function(req,res){ upload