multer - req.file always undefined : <p>I've looked at a lot of answer for this same question, but I haven't found a working solution yet. I am trying to make a web app that you can upload files to using express and multer, and I am having a problem that no files are being uploaded and req.file is always undefined.</p>

<p>My code below</p>

<pre><code>'use strict';

var express = require('express');
var path    = require('path');
var multer  = require('multer')
var upload  = multer({ dest: 'uploads/' })

var app = express();
require('dotenv').load();

app.use(express.static(path.join(__dirname, 'main')));

app.post('/upload', upload.single('upl'), function (req, res, next) {
  // req.file is the `avatar` file
  // req.body will hold the text fields, if there were any
  console.log(req.file);
  res.status(204).end();
})

var port = process.env.PORT || 8080;
app.listen(port,  function () {
    console.log('Node.js listening on port ' + port + '...');
});
</code></pre>

<p>The form</p>

<pre><code>    &lt;form class="uploadForm" action="/upload" method="post" enctype="multipart/formdata"&gt;
        &lt;label class="control-label"&gt;Select File&lt;/label&gt;
        &lt;input name="upl" id="input-1" type="file" class="file"&gt;
        &lt;input type="submit" value="submit" /&gt;
    &lt;/form&gt;
</code></pre>

<p>Help very much appreciated, this is driving me crazy.</p>
