title: Trying to save base64 (image) file to server, it's empty
body: <p>I'm trying to save a canvas image to a folder in my server however the file is empty upon inspection. I'm using AJAX to pass the encoded data to my php script, and then the php script is saving it to the server, empty.</p>
  
  <p>This is the code I have:</p>
  
  <p>JS/AJAX:</p>
  
  <pre><code>function convertCanvasToImage(thecanvas) {
                  var ajax = new XMLHttpRequest();
                  ajax.open("POST",'testSave.php',false);
                  ajax.setRequestHeader('Content-Type', 'application/upload');
                  ajax.send(canvasData);
              }
  </code></pre>
  
  <p>PHP (testSave.php):</p>
  
  <pre><code>    $imageData=$GLOBALS['HTTP_RAW_POST_DATA'];
  
      $filteredData=substr($imageData, strpos($imageData, ",")+1);
  
      $unencodedData= base64_decode($filteredData);
  
      //echo "unencodedData".$unencodedData;
  
      $fp = fopen( 'test.png', 'wb' );
      fwrite( $fp, $unencodedData);
      fclose( $fp );
  </code></pre>
  
  <p>Thanks for any help in advance!</p>