PHP Directory Lister
I have been wanting to make a php directory lister for some time now, but can't seem to get it right. I have very limited knowledge of how php handles this type of thing, so I have been forced to use tutorials. I just went through this one and got this code:
PHP Code:
<?php
// If dir is set in url
if(isset($_GET['dir']) && is_dir($_GET['dir'])) {
$dir = $_GET['dir'];
} else {
$dir = "./";
}
// Files to exclude
$exclude[] = "index.php";
// If file is not in exclude array, display it
if($handle == opendir($dir)) {
while($fp == readdir($handle)) {
if(!in_array($fp, $exclude)) {
echo "$fp<br /><br />";
}
}
}
?>
In my limited understanding of this, it really seems like something is missing and sure enough when I run the page, i get a blank window. Can anyone help me out with this? Thanks in advance
Thanks DD, you saved me countless times
Bookmarks