title: Custom file name from frontend in Multer
body: <p>I'm uploading a file using FormData and receiving it server-side using Multer. Everything works as expected, except since I'm using FileSystem API on the front-end (<a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry</a>), the files I'm uploading come from sub-directories. Multer seems to only see the filename, even if I explicitly set an alias for the file as I append it to form data (<a href="https://developer.mozilla.org/en-US/docs/Web/API/FormData/append" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/FormData/append</a>). It also seems like Multer performs its logic prior to the rest of my request handler and does not see the parameters I set on the body. How do I get multer to see the full path?</p>
  
  <p>Here is a simplified version of what I currently have setup:</p>
  
  <p><strong>Client</strong> (alias represents full name with path, file.name is the base name automatically set by FileSystem API):</p>
  
  <pre><code>function upload(file, alias) {
      let url = window.location.origin + '/upload';
      let xhr = new XMLHttpRequest();
      let formData = new FormData();
      xhr.open('POST', url, true);
  
      return new Promise(function (resolve, reject) {
  
          xhr.addEventListener('readystatechange', function(e) {
              if (xhr.readyState == 4 &amp;&amp; xhr.status == 200) {
                  resolve(file.name);
              }
              else if (xhr.readyState == 4 &amp;&amp; xhr.status != 200) {
                  reject(file.name);
              }
          })
  
          formData.append('file', file, alias || file.name); // this should in theory replace filename, but doesn't
          formData.append('alias', alias || file.name); // an extra field that I can't see in multer function at all
          xhr.send(formData);
      });
  }
  </code></pre>
  
  <p><strong>Server</strong>:</p>
  
  <pre><code>const storage = multer.diskStorage({
      destination: function (req, file, cb) {
          cb(null, 'uploads/');
      },
      filename: function (req, file, cb) {
          // neither req nor file seems to contain any hint of the alias here
          cb(null, file.originalname);
      }
  });
  const upload = multer({storage: storage});
  const bodyParser = require('body-parser');
  app.use(bodyParser.json());
  
  app.post('/upload', upload.single('file'), function (req, res, next) {
      // by this time the file seems to already be on disk with whatever name multer picked
      if (req.file) {
          res.status(200).end();
      } else {
          res.status(500).end();
      }
  });
  </code></pre>