title: Famous TypeError: Cannot read property 'path' of undefined with multer
body: <p>I'm having an issue will uploading a docx file with multer.</p>
  
  <p>What i've declared :</p>
  
  <p><strong>app.js multer config</strong></p>
  
  <pre><code>var storage = multer.diskStorage({
    destination: function(req, file, callback) {
      callback(null, __dirname + process.env.UPLOAD_DIR); // '/uploads'
    }
  });
  var uploadService = multer({
    storage: storage,
    // limits: { fileSize: maxSize },
    fileFilter: function(req, file, callback) {
      var ext = path.extname(file.originalname)
      if (ext !== '.docx') {
        return callback(res.end('Only docx are allowed'), null)
      }
      callback(null, true)
    }
  });
  app.post('/upload', uploadService.single('file'), uploadController.postFileUpload);
  </code></pre>
  
  <p><strong>upload.js</strong></p>
  
  <pre><code>exports.postFileUpload = (req, res, next) =&gt; {
    // Data receiver parameters
    var jsonData = '';
    var buffer = generateDoc(jsonData, req.file);
  [...]
    res.status(200).end();
  };
  
  
  function generateDoc(data, file) {
    var doc = new Docxtemplater();
    var wordDocument = file;
    var filepath = wordDocument.path;
    console.log(filepath); // prints file path ex : D:\doc_tpl\uploads\0816cdb5c82d458ed930d0048b603d8a
    var content = fs.readFileSync(path.resolve(filepath), 'binary'); // throws error, wtf ?
   [...]
    return buffer;
  }
  </code></pre>
  
  <p>Then i've got this error : </p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'path' of undefined
        at generateDoc (D:\doc_tpl\controllers\upload.js:17:31)</p>
  </blockquote>
  
  <p>I can't use the var, and, as you can see, passing through another variable wont fix the problem.. </p>
  
  <p>I'm using Node@8.7 , "express": "^4.15.4", "multer": "^1.3.0". And my pug html body seems clean :</p>
  
  <pre><code>form#file-uploader.dropzone(method='post', action='/upload' enctype='multipart/form-data')
    .fallback
      input(name='file' type='file')
  </code></pre>
  
  <p>What's wrong on this code ? </p>