Skip to content
Related Articles

Related Articles

How to create directory with HTML button and PHP ?

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Easy
  • Last Updated : 30 Jan, 2019

The mkdir() function is used to create directory in PHP. It is an inbuilt function in PHP. The mkdir() function creates a new directory with the specified pathname. The path and mode are sent as parameters to the mkdir() function and it returns TRUE on success or FALSE on failure.


mkdir( path, mode, recursive, context )

Return Value: This function returns TRUE on success, or FALSE on failure.


<!DOCTYPE html>
    function createDirectory() {
        $add = $_POST["add"];
        mkdir("Gfg ".$add);
        echo "<script type = 'text/javascript'>alert('Done!');</script>";
            Create directory with HTML button and PHP 
        if (!isset($_POST['submit'])) {
        <form action = "" method = "post">
                <td style = " border-style: none;"></td>
                <td bgcolor = "lightgreen" style = "font-weight: bold">
                    Enter Dummy Text and Then Press 'Create Directory'
                <td bgcolor = "lightred">
                    <input type = "text" style = "width: 220px;" 
                    class = "form-control" name = "add" id = "add" />
                <td bgcolor = "lightgreen" colspan = "2">
                    <input type = "submit" name = "submit" 
                        value = "Create directory" /> 
        else {


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!