mkdir function is used to create folder or directory in php.
Syntax:
mkdir($str, 0777, true)
Please share your comments and feebback.Thanks.Please subscribe my updates via email.
Syntax:
mkdir($str, 0777, true)
PHP Code
<?php
if(isset($_POST['createdirectory']))
{
$folder='D:\phptest\\'; // Desired folder path
$foldername=$_POST['foldername'];
$foldercreate=$folder . $foldername;
if (!mkdir($foldercreate, 0777, true))
{
die('Failed to create folder...');
}
else
{
echo "Folder has been created successfully!";
}
$foldercreate="";
}
?>
if(isset($_POST['createdirectory']))
{
$folder='D:\phptest\\'; // Desired folder path
$foldername=$_POST['foldername'];
$foldercreate=$folder . $foldername;
if (!mkdir($foldercreate, 0777, true))
{
die('Failed to create folder...');
}
else
{
echo "Folder has been created successfully!";
}
$foldercreate="";
}
?>
HTML Form
<form action="#" method="post">
Enter Name of the folder:
<input type="text" name="foldername" size="15" required />
<input type="submit" name="createdirectory" value="Create" />
</form>
Enter Name of the folder:
<input type="text" name="foldername" size="15" required />
<input type="submit" name="createdirectory" value="Create" />
</form>
Complete Code
<form action="#" method="post">
<h3>Directory (or) Folder Creation in PHP:</h3>
Enter Name of the folder:
<input type="text" name="foldername" size="15" required />
<input type="submit" name="createdirectory" value="Create" />
<?php
if(isset($_POST['createdirectory']))
{
$folder='D:\phptest\\'; // Desired folder path
$foldername=$_POST['foldername'];
$foldercreate=$folder . $foldername;
if (!mkdir($foldercreate, 0777, true))
{
die('Failed to create folder...');
}
else
{
echo "Folder has been created successfully!";
}
$foldercreate="";
}
?>
</div>
</form>
<h3>Directory (or) Folder Creation in PHP:</h3>
Enter Name of the folder:
<input type="text" name="foldername" size="15" required />
<input type="submit" name="createdirectory" value="Create" />
<?php
if(isset($_POST['createdirectory']))
{
$folder='D:\phptest\\'; // Desired folder path
$foldername=$_POST['foldername'];
$foldercreate=$folder . $foldername;
if (!mkdir($foldercreate, 0777, true))
{
die('Failed to create folder...');
}
else
{
echo "Folder has been created successfully!";
}
$foldercreate="";
}
?>
</div>
</form>
No comments:
Post a Comment