PHP create directory or folder in server


In this example i am going to explain how to create a directory using PHP and MySQLi .

index.html

<!DOCTYPE html>
 <html>
 <body>
<form action="CreateFolder.php" method="post">
    <h2>
        Create New Folder
    </h2>
    <input name="createfolder" type="text">
    <input type="submit" value="Create Folder">
</form>
</body>
</html>

CreateFolder.php

CreateFolder.php

<?php $folder_name=$_POST['createfolder']; if (!file_exists($output_dir . $folder_name))/* Check folder exists or not */ { @mkdir($output_dir . $folder_name, 0777);/* Create folder by using mkdir function */ echo "Folder Created";/* Success Message */ } ?>