title: How to convert html to base64 and save an image on a server with php?
body: <p>I have a json file like this:</p>
  
  <pre><code>{"user":{"email":"user@test.com"},
   "screenshot":{"blobFile":"&lt;!DOCTYPE html&gt;&lt;html lang=\"en\"&gt;...&lt;/html&gt;"}}
  </code></pre>
  
  <p>and I want to take a screenshot, using XMLHttpRequest sending data a PHP file.</p>
  
  <p>In PHP file getting request like:</p>
  
  <pre><code>$data = json_decode(file_get_contents("php://input"), true);
  $htmlStr = json_encode($data["screenshot"]["blobFile"]); // &lt;!DOCTYPE html&gt;&lt;html lang=\"en\"&gt;...
  </code></pre>
  
  <p>so far everything is ok but how to convert this string to the image file and save a server?</p>
  
  <p>I've tried <a href="https://html2canvas.hertzen.com/" rel="nofollow noreferrer">html2canvas</a> in PHP file but not fire.</p>
  
  <p>any ideas? </p>