<?php
	header('Access-Control-Allow-Origin: *');
	header('Access-Control-Allow-Credentials: true');
	
	$data = $_REQUEST['base64data']; 
	$imgName = $_REQUEST['filename']; 

	$image = explode('base64,',$data); 

	file_put_contents("FaceCake_NARS_Try-On_" . $imgName . '.png', base64_decode($image[1]));
	
	$path =  'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
	
	echo json_encode(array('imgPath'=> $path . '/FaceCake_NARS_Try-On_' . $imgName . '.png', 'img'=> 'FaceCake_NARS_Try-On_' . $imgName . '.png'));
?>