title: canvas image to php
body: <p>I know this question was already here a lot, but none of solutions looks to be working for me. 
  So, I am using Kinetics.js and I have build an canvas application where people can draw their images (pretty simple). The idea is that when image is ready user would go to the next page, but I need his drawing to be saved as a file at server.</p>
  
  <p>Here is my code:
  JavaScript:</p>
  
  <pre><code>$('#someButton').click(function(){
  hiddenCanvas.toDataURL({
          callback:function(dataUrl){
              $.ajax({
              type: "POST",
              url: "scripts/imgsave.php",
              data: {image: dataURL}
              });
  
              }
              });
  
      window.location = 'scripts/imgsave.php'; 
  )};
  </code></pre>
  
  <p>And PHP:</p>
  
  <pre><code>if ( isset($_POST["image"]) &amp;&amp; !empty($_POST["image"]) ) {    
  $dataURL = $_POST["image"];  
  $parts = explode(',', $dataURL);  
  $data = $parts[1];  
  $data = base64_decode($data);  
  $fp = fopen('../images/test.png', 'w');  
  fwrite($fp, $data);  
  fclose($fp); 
  }
  </code></pre>
  
  <p>The problem is, that whatever I do, PHP saves empty file on my server. So I guess the dataURL is not send properly. What could be the issue here?</p>