Chrome Extension

Check if a folder already created using PHP

You can use this code to check whether a folder or directory already exists or not. We are using a PHP script to check that.
<?php
    $newdirname = $_POST["new_dir_name"];
    $dir_path = "path/to/" . $newdirname . "/";

    if (!file_exists($dir_path)) {
        mkdir($dir_path, 0777);
        echo "The directory creted successfully.";
        exit;
    } else {
        echo "The directory already exists.";
    }    
?>
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Was this helpful?
0 Comments
Join Devsheet Ask a Question