title: Node/Express file upload
body: <p>I'm using node v0.10.26 and express v4.2.0 and I'm pretty new to node.  I've been beating my head against my desk for the past three or so hours trying to get a file upload form working with node.  At this point I'm just trying to get req.files to not return undefined. My view looks like this</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;{{ title }}&lt;/title&gt;
    &lt;link rel='stylesheet' href='/stylesheets/style.css' /&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;{{ title }}&lt;/h1&gt;
    &lt;p&gt;Welcome to {{ title }}&lt;/p&gt;
    &lt;form method='post' action='upload' enctype="multipart/form-data"&gt;
      &lt;input type='file' name='fileUploaded'&gt;
      &lt;input type='submit'&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here are my routes</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  
  /* GET home page. */
  router.get('/', function(req, res) {
    res.render('index', { title: 'Express' });
  });
  
  router.post('/upload', function(req, res){
  console.log(req.files);
  });
  
  module.exports = router;
  </code></pre>
  
  <p>And here's my app.js</p>
  
  <pre><code>var express = require('express');
  var path = require('path');
  var favicon = require('static-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  
  var routes = require('./routes/index');
  var users = require('./routes/users');
  
  var app = express();
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'hjs');
  
  app.use(favicon());
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded());
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.use('/', routes);
  app.use('/users', users);
  
  /// catch 404 and forward to error handler
  app.use(function(req, res, next) {
      var err = new Error('Not Found');
      err.status = 404;
      next(err);
  });
  
  /// error handlers
  
  // development error handler
  // will print stacktrace
  if (app.get('env') === 'development') {
      app.use(function(err, req, res, next) {
          res.status(err.status || 500);
          res.render('error', {
              message: err.message,
              error: err
          });
      });
  }
  
  // production error handler
  // no stacktraces leaked to user
  app.use(function(err, req, res, next) {
      res.status(err.status || 500);
      res.render('error', {
          message: err.message,
          error: {}
      });
  });
  
  
  
  module.exports = app;
  </code></pre>
  
  <p>I saw somewhere that including <code>methodOverride()</code> and <code>bodyParser({keepExtensions:true,uploadDir:path})</code> was supposed to help but I can't even launch my server if I add those lines. </p>