▼  Site Navigation Main Articles News Search  ▼  Anime + Manga Anime Reviews Anime Characters Gallery Screenshots Manga Reviews  ▼  Misc Links to Webcomics Bible Quotes About Older Musings
site version 7.3
PHP –– list the files and directories in a folder
written by: admin


Date Written: 9/22/07 Last Updated: 1/15/10

This script will list the files and directories in a given folder.
<?php
  session_start();
if ( @$_SESSION['pasword']  != "password" )
{
header("location: redirect.php");
exit();
}
?>
<STYLE TYPE="TEXT/CSS">
textarea{background-color:#a9a9a9;color:black;}
body{
background-color:tan;
}
</style>
<?php
$url=@$_POST['url'];
if ($url != "")
{
$handle=@opendir($url) or exit("bad file name<br> <a href=\"list_files.php5\">go back</a>");
while (false !== ($file = @readdir($handle))) {
$pos = strpos($file, '.');
if ($pos === false) {$file.=str_replace($file,"\n"," -- DIRECTORY");}

$data .= $file ."\n";
}@fclose($handle);
}

$string="";
?>

<form action=<?php echo $_SERVER['PHP_SELF']; ?> method="POST">
contents of folder:<br><textarea name="data" cols=95 rows=25>
<?php print htmlentities($data);?>
</textarea><br><br>
enter the relative location of the folder you want to browse here:<br>
<input type="text" name="url" cols=75 value=<?php echo @$_POST['url']; ?> >
<br><br>
<input type='submit' name="queryButton" value="Submit">

</form>


TAGS: php
copyright 2005–2024