<?php 
	error_reporting(0);
	date_default_timezone_set('Asia/Kuala_Lumpur');
	/*
	error_reporting(E_ALL);
	ini_set('display_errors', TRUE);
	ini_set('display_startup_errors', TRUE);
	*/
	
	
	
	$f_type			= $_POST['f_type'];
	
	$filename		= $_POST['fileName'];
	$filepath		= $f_type."/images/";
	
	
	// Handle remote upload
	if (isset($_POST['fileName']) && $_POST['fileData'] && $f_type)
	{
		// make sure file is image (base64encoded, so now need "fromstring")
		$extension = getimagesizefromstring(base64_decode($_POST['fileData']));
		if($extension){
			//get extension
			$extension = image_type_to_extension($extension[2]); //[2] = img type in long
			// Save uploaded file
			file_put_contents(
				$filepath.$filename.$extension,
				base64_decode($_POST['fileData'])
			);
		
			// Done
			echo "http://ewin2u1.com/landing/txt/".$filepath.$filename.$extension; //Success
		}else{
			echo "0"; //Bad file type
		}
	}
?>