<?php
//the global file operation
session_start();
ob_start();
$xx=$_POST["name"];
//Get the base-64 string from data
$filteredData=substr($_POST["name"], strpos($_POST["name"], ",")+1);
//Decode the string
$unencodedData=base64_decode($filteredData);
//Save the image
$randomname =md5( uniqid(mt_rand(),true));
file_put_contents('receptimage/'.$randomname.'.png', $unencodedData);
echo $randomname.'.png';
?>