<?php 
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
if(($_POST['test'])!=""){
	
$img = $_POST['test']; // Your data 'data:image/png;base64,AAAFBfj42Pj4';
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace('data:image/jpeg;base64,', '', $img);
$img = str_replace('data:image/jpg;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$a=file_put_contents($_POST['folder'].'/'.$_POST['name'].'.jpeg', $data);

}

if($a){
$rep="On";
}else{
	$rep="Off";
}


echo '{"repnse":"'.$rep.'"}';


?>