Current File : /home/users/barii/public_html/finansenl.com.pl/wodki/admin/tablice/js/saveJson.php
<?php

     $arr = array('.jpg','.png');  
     $arr2 = array('','');   

$text = str_replace("\\n",chr(-164).chr(-164).'n',$_POST['json']);
$text = str_replace('null,{','{',$text);


$img = $_POST['imgBase64'];
$img = str_replace('data:image/jpeg;base64,', '', $img);
$fileData = base64_decode($img);
$fileName = $data.'.jpg';
file_put_contents('../img/mini/makiety/'.$_POST['funct'], $fileData);

                $image = new Imagick('../img/mini/makiety/'.$_POST['funct']); 
                $image->setimageresolution(72, 72);                       
                $image->scaleimage(700,0);               
                $image->writeimage('../img/mini/makiety/'.$_POST['funct']);

$file = 'zapisanejson.js';
$function  = file_get_contents($file);


$_POST['funct'] = str_replace($arr,$arr2,$_POST['funct']);

$function .= '
function '.str_replace('/','_',($_POST[funct])).'(scale){
var json = \''.$text.'\';
canvas.loadFromJSON(json);
}';

file_put_contents($file, $function."\n");

?>