<?php
	
	$dirpath="apis/userdata";
	$myObj=new stdClass();
	$errorfound=false;
	if(!file_exists($dirpath))
	{
		$errorfound=true;
		$myObj->result = "error";
		$myObj->msg= $dirpath.' path not exist';
		echo json_encode($myObj);
	}
	else
	{

		try {
			$content = "some text here";
			$fp = fopen($dirpath."\myText.txt","wb");
			fwrite($fp,$content);
			fclose($fp);	

			unlink($dirpath."\myText.txt");
		} catch (Exception $e) {
			$errorfound=true;
			$myObj->result = "error";
			$myObj->msg='Error While Writing file. '. $e->getMessage() ;
			echo json_encode($myObj);
		}
	}

	if( $errorfound==false )
	{
		$myObj->result = "success";
		$myObj->msg='System Check Done.';
		echo json_encode($myObj);	
	}

?>