<?php
// array for JSON response
  $response= array();

    // if (isset($_POST['DisplayImage']) && isset($_POST['Name'])){

      $DisplayImage = $_POST['DisplayImage'];
	  $Name = $_POST['Name'];

      $folder = "ChatApp/ChatImages";
      
      $path = $folder;
      
      if (!file_exists($path)) {
            mkdir($path, 0777, true);
      }
      
      $decodedImage = base64_decode($DisplayImage);
      $return = file_put_contents($path."/".$Name, $decodedImage);

      // success
      $response["success"] = 1;
      $response["message"] = $return;
      // echoing JSON response
      echo json_encode($response);
//     }else{
// 		// success
//       $response["success"] = 0;
//       $response["message"] = "IMAGE NOT SEND";
//       // echoing JSON response
//       echo json_encode($response);
// 	}
?>
