title: Save file to mongodb using angular and Nodejs
body: <p>I am trying to upload an image to mongodb using angular and nodejs. The code is below. I got the backend working but the problem is with the html input i get 'C:fakepath/file.xyz'. I was looking online and saw that there is not a way to get the relative path of the file. Can someone please tell me how i can change my front end code to get and send the file path to the backend to then save. I read that the browser doesnt allow relative path of the file but then how can I upload. Thanks!</p>
  
  <p>The nodejs image save method is:</p>
  
  <pre><code> async function SaveImage(userParam) {
      const entry = new imageEntries(userParam);
      entry.image.data = fs.readFileSync(userParam.imagePath);
      entry.image.contentType = 'image/png';
      await entry.save();
      }
  </code></pre>
  
  <p>The html code is:</p>
  
  <pre><code>&lt;div class="upload-btn-wrapper"&gt;
    &lt;button class="btn"&gt;Upload a file&lt;/button&gt;
    &lt;input type="file" name="myfile" id="myFile" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I pass as the path in the backend is:</p>
  
  <pre><code>ImageJournal.imagePath = (&lt;HTMLInputElement&gt;document.getElementById('myFile')).value;
  </code></pre>
  
  <p>but with the code above i get the following error:</p>
  
  <pre><code>ENOENT: no such file or directory, open 'C:\fakepath\chapter9problemsandanswers.doc'
  </code></pre>