MKDIR 3 levels above using php
level1/level2/level3/CWD/mkdir.php
Name of Level1 is not known; is user specified & can be anything. Name of
level2 & level3 is known and will remain static. Current Working Directory
contains mkdir.php file that is required to create a directory in level1
with user provided name. The mkdir.php file below does the job, but don't
know whether it's the correct way. Want experts to approve and advice.
Thanks in advance.
<?php
if (isset($_POST['Name']))
{
$newdir = $_POST['Name'];
$dirname = "..\\$newdir";
$step1 = "..\\CWD";
$step2 = "..\\$step1";
$step3 = "..\\$step2\\$dirname";
if (mkdir($step3, 0777, true))
{
echo "dir created successfully";
}
else
{
echo "dir not created";
}
}
?>
No comments:
Post a Comment