title: Pass Files to Node Server
body: <p>Im having this function in my react app, what is does is sending a file to the server and the server save it to the declared dir.</p>
  <pre><code>      const handleUploadfile = (event) =&gt; {
          event.preventDefault();
          const data = new FormData();
          data.append('file',file );
  
          fetch(&quot;http://localhost:4000/upload&quot;, {
               method: 'POST',
               body: data
          }).then((response) =&gt; console.log(response))
  
        }
  </code></pre>
  <p>heres the code in the node server handling the request above</p>
  <pre><code>app.post(&quot;/upload&quot;, (req, res) =&gt; {
    const newpath = &quot;./files/&quot;;
    const file = req.files.file;
    const filename = file.name;
  
    file.mv(`${newpath}${filename}`, (err) =&gt; {
      if (err) {
        res.status(500).send({ message: &quot;File upload failed&quot;, code: 200 });
      }
      res.status(200).send({ message: &quot;File Uploaded&quot;, code: 200 });
    });
  });
  </code></pre>
  <p>The upload is working well, but what i want to know is, am i able to include some data like a string directory for each uploaded file something like that.</p>
  <p>BTW im using express-uploadfile middleware so i can access the files.</p>