title: Pushing images from "/images/" folder on server to mongoDB
body: <p>So my main goal is that I can save images into user documents into mongoDB. 
  So far I have been able to save the uploaded image to my servers temporary images folder and I can't for the life of me figure out how to push it to mongoDB.</p>
  
  <p>Please note that this function will be used when a new user registers on my site and they will be able to upload a profile picture during the registration process.</p>
  
  <p><strong>So far I have done:</strong></p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data" action="/file-upload"&gt;
  &lt;input type="file" name="thumbnail"&gt;
  &lt;input type="submit"&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>// we need the fs module for moving the uploaded files
   var fs = require('fs');
  
   app.post('/file-upload', function(req, res) {
  
      // get the temporary location of the file
      var tmp_path = req.files.thumbnail.path;
  
      // set where the file should actually exists - in this case it is in the "images" directory
      var target_path = './images/' + req.files.thumbnail.name;
  
      // move the file from the temporary location to the intended location
      fs.rename(tmp_path, target_path, function(err) {
          if (err) throw err;
  
          // delete the temporary file, so that the explicitly set temporary upload dir does not get filled with unwanted files
  
          fs.unlink(tmp_path, function() {
              if (err) throw err;
              res.send('File uploaded to: ' + target_path + ' - ' + req.files.thumbnail.size + ' bytes');
          });
        });
      });
  </code></pre>
  
  <p><strong>The above code works and I can see the image being uploaded into my images folder on the server but how can I post this mongoDB?</strong></p>