Space for google add

A program to read directory name from user and display content of the directory recursively.



A program to read directory name from user and display content of the

directory recursively.


a3setc1.html

<html>

<body>

<form method="post" action="dir1.php">

Enter directory name:

<input type="text" name="dname"><br>

<input type='submit' name='submit' value='submit'>

<input type='reset' name='reset' value='reset'>

</form>

</body>

</html>


dir1.php

<?php

$d=$_POST['dname'];

function hello($d)

{

if(is_dir($d))

{

$dp=opendir($d);

if($dp)

{

while($filename=readdir($dp))

{

if(is_dir("$d/$filename"))

{

if($filename!="." && $filename!="..")

hello("$d/$filename");

}

else

{

echo "$filename<br>";

}

}

}

else

echo "directory not opened";

}

else

echo "Not a directory";

}

hello($d);

closedir($dp);

?>


Post a Comment

0 Comments