title: upload an image using busboy meanstack undefined
body: <p>I'm trying to make a sign up form with an image upload ability so I take the values on the ejs side using this by a post and enctype = "multipart/form-data"</p>
  
  <pre><code>&lt;form method="post" action= "/SignUp" enctype="multipart/form-data" &gt;
      &lt;div class="form-group"&gt;
          &lt;label for="firstName"&gt;First name&lt;/label&gt;
          &lt;input type="text" name="firstName" id="firstName" class="form-control" value="&lt;%= locals.firstName || '' %&gt;" required /&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="lastName"&gt;Last name&lt;/label&gt;
          &lt;input type="text" name="lastName" id="lastName" class="form-control" value="&lt;%= locals.lastName || '' %&gt;" required /&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="username"&gt;Username&lt;/label&gt;
          &lt;input type="text" name="username" id="username" class="form-control" value="&lt;%= locals.username || '' %&gt;" required /&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="password"&gt;Password&lt;/label&gt;
          &lt;input type="password" name="password" id="password" class="form-control" required /&gt;
      &lt;/div&gt;
      &lt;div class = "from-group"&gt;
        &lt;label for = "Image"&gt;Image&lt;/label&gt;
        &lt;input Content-Type = "multipart/form-data" type ="file" name = "Image" id = "Image" class = "form-control" required/&gt;
      &lt;/div
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;div class="form-group"&gt;
          &lt;button type="submit" class="btn btn-primary"&gt;Register&lt;/button&gt;
          &lt;a href="/login" class="btn btn-link"&gt;Cancel&lt;/a&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and I handle it from the server side using busboy </p>
  
  <pre><code>  SignUp:function(req,res){
    let reg = new Registrations();
    var busboy = new Busboy({
      headers: req.headers,
      limits: {
        fileSize: 6*1024*1024 //2MB limit
      }
    });
      var stream;
      var fstream;
         busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated) {
           if(fieldname == 'firstName')
           reg.firstName = val;
           else if (fieldname == 'lastName')
            reg.lastName = val;
            else if(fieldname == 'username')
            reg.username = val;
            else {
              reg.password = val;
            }
  
  
         })
        busboy.on('file', function(fieldname,file, filename,encoding,mimeType){
        stream = __dirname + '/img/' + filename;
        fstream = fs.createWriteStream(__dirname + '/img/' + filename);
        file.pipe(fstream);
        fstream.on('close', function(){
            reg.Image = stream;
          reg.save(function(err,reg){
            if(err){
              res.send(err.message)
              console.log(err);
            }else{
              console.log(reg);
            }
          })
        })
      })
      busboy.on('finish', function() {
  
      })
      res.render('login');
  
    }
  </code></pre>
  
  <p>it shows me this error every time I try it<br>
  TypeError: Cannot read property 'on' of undefined on the line</p>
  
  <pre><code>req.busboy.on('file', function(fieldname,file, filename,encoding,mimeType)
  </code></pre>
  
  <p>Can you please tell me what is this problem about ?</p>