title: How to display image inside HTML document using node.js
body: <p>I'm displaying some text that i've created inside HTML file using node.js (by method createServer).</p>
  
  <p>Everything was working fine until i added picture inside the document, which doesn't get display on the site.</p>
  
  <p><strong>This is my code</strong></p>
  
  <pre><code>http.createServer(function (req, res) {
  
  res.writeHead(200, { 'Content-Type': 'text/html'});
  
  
  //read HTML
  fs.readFile(__dirname + '//funkcionalnosti.html', function (err, data) {    
      console.log(data.toString());
      res.end(data);
  });
  </code></pre>
  
  <p><strong>This is my code for image inside HTML file</strong>
  <a href="https://i.stack.imgur.com/RaGyE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RaGyE.jpg" alt="enter image description here"></a></p>
  
  <p><strong>And this is where picture is located</strong></p>
  
  <p>Picture as located same as HTML file, so i dont any <strong>../</strong> are necessary in order for it ti work. I've also tried adding the ful path and subdirectories but the picture won't show.</p>
  
  <p><a href="https://i.stack.imgur.com/ceBCr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ceBCr.jpg" alt="enter image description here"></a></p>
  
  <p><strong>I've also tried this that i found on stackoverflow, but it's still not working</strong></p>
  
  <pre><code>var image_origial = "diagram.jpg";
  fs.readFile(image_origial, function (err, original_data) {
      fs.writeFile('diagram.jpg', original_data, function (err) { });
      var base64Image = original_data.toString('base64');
      var decodedImage = new Buffer(base64Image, 'base64');
      fs.writeFile('diagram.jpg', decodedImage, function (err) { });
  });
  </code></pre>
  
  <p><strong>Also tried this</strong></p>
  
  <pre><code>res.write('&lt;img src="data:diagram.jpg/;base64,imagedata"&gt;');
  </code></pre>
  
  <p><strong>Or this</strong></p>
  
  <pre><code>res.write('&lt;img src="data:diagram.jpg/jpg;base64,imagedata"&gt;');
  </code></pre>
  
  <p>But no luck so far, please help me out, im desperate</p>
  
  <p><strong>Any help will be appreciated!!!</strong></p>
  
  <p><strong>How is this a duplicate to "bundle.js:1 Uncaught SyntaxError: Unexpected token &lt;" ?</strong></p>