title: How to limit the file size when uploading with multer?
body: <p>I'm making a simple file upload system with multer:</p>
  
  <pre><code>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 &gt; maxSize) {
        return false;
      }
    }
  
  });
  
  var upload = multer({ storage : storage}).single('bestand');
  
  router.post('/upload',function(req,res){
      upload(req,res,function(err) {
          if(err) {
              return res.end("Error uploading file.");
          }
          console.log(req.file);
          res.redirect(req.baseUrl);
      });
  });
  </code></pre>
  
  <p>This all works fine and the file gets uploaded. The only thing that is not working is the limit on the max size. I made it so that onfileupload start the size of the file gets checked and if its to big it will return false. But the file still just gets uploaded. </p>
  
  <p>It seems that <code>onFileUploadStart</code> isn't doing anything at all. I tried to <code>console.log</code> something in it, but nothing.</p>
  
  <p>What am I doing wrong? How can I limit the file size when uploading with multer?</p>