Space for google add

Write a program to read directory name and extension. Display the files with specified extension from that directory.


 

Write a program to read directory name and extension. Display the files with

specified extension from that directory.


a3setb2.html

<html>

<body>

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

Enter directory name:

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

Enter extention name:

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

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

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

</form>

</body>

</html>


a3setb2.php

<?php

$dir=$_POST['dname'];

$e=$_POST['ename'];

if(is_dir($dir))

{

$dp=opendir($dir);


if($dp)

{

while($file=readdir($dp))

{

if(stristr($file,$e))

echo "<br> $file <br>";

}

}

closedir($dp);

}

else

echo "<br>Directory type error.<br> ";

?>


Post a Comment

0 Comments