title: express multer Cannot read property 'profileimage' of undefined
body: <p>I am trying to submit a form which has a file input within it with a name of <code>profileimage</code>, i am using express 4, express generator and multer.</p>
  
  <p>In my <code>app.js</code> I added multer like so:</p>
  
  <pre><code>var multer = require('multer');
  var upload = multer({ dest: './uploads' });
  </code></pre>
  
  <p>The tutorial i am following actually sets up multer like so (after requiring it) but it gives me an error:</p>
  
  <pre><code>app.use(multer({dest: './uploads'}));
  </code></pre>
  
  <p>And in my <code>routes</code> folder inside the respective file I have the following:</p>
  
  <pre><code>router.post('/register', function(req, res, next) {
  // get form values
  var name = req.body.name;
  var email = req.body.email;
  var username = req.body.username;
  var password = req.body.password;
  var password2 = req.body.password2;
  
  // check for image field
  if (req.files.profileimage)
  {
      console.log('Uploading file...');
  ...
  </code></pre>
  
  <p>However when I submit the form I get the following error:</p>
  
  <pre><code>Cannot read property 'profileimage' of undefined
  </code></pre>
  
  <p>It seems to not be able to understand <code>req.files.profileimage</code>, but I don't know why?</p>