<?php
$postData = file_get_contents("php://input");

if(isset($postData) && !empty($postData)) {
    $request = json_decode($postData, true);
    $username = $request['username'];
    $dirname = $request['dir_name'];
    $path = "../users/" . $username . "/" . $request['curr_dir'] . "/" . $dirname;

    if(file_exists($path)) {
        $msg = "directory already exists";
        clearstatcache();
        echo json_encode($msg);
    }
    else {
        mkdir($path, 0777, true);
        echo json_encode("Success");
        clearstatcache();
    }

}
?>