Hi I have a DataURL https://www.dropbox.com/s/xrt465wlnuzwogf/data.rtf (I have tested the dataURL and it renders an image) that I'm sending to a php file. var myImage = the dataURL This is the JS:
$.ajax({
type:"POST",
url: "php/save.php",
data: "img="+myImage+"&random="+random,
success: function(){
}
});
This is the PHP taken from here and modified a bit:http://j-query.blogspot.in/2011/02/save-base64-encoded-canvas-image-to-png.html this is the php:
<?php
$random = $_REQUEST['random'];
$img = $_REQUEST['img'];
// requires php5
define('UPLOAD_DIR', '/');
//$img = $_POST['img'];
//echo($img);
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
?>
The file is being created on my server 2742img.png but at 0B (no data). Does anybody know what might be stoping the file from saving?
Thanks.