PHP mkdir() function – Create Directory



PHP mkdir() Function

Create Directory in PHP

The mkdir() function is used to create a new directory in computer.

mkdir() function syntax

<?php

mkdir(“directory_name”);

?>

mkdir() function Exmaple

<?php

mkdir("meera");

?>

Above example we use mkdir() function to create directory named with “meera”.

The new directory created in the php script folder.

PHP form script example to create directory

<HTML>
<head>
<title>Create Directory in PHP</title>
</head>
<body>
<FORM method="POST">
Enter Directory Name : <input type="text" name="str"> <br/> <br/>
<input type="submit" name="Submit1" value="Create Directory">
</FORM>

<?php
if(isset($_POST["Submit1"]))
{
mkdir($_POST["str"]);
echo "Directory Created.";
}
?>
</body>
</HTML>

The output of create directory using mkdir() php example is:

PHP mkdir() function
PHP mkdir() function example for create directory.

 

Leave a Reply

Your email address will not be published. Required fields are marked *