Okay so this still isn't working for me but it is echoing the correct directory so i'm doing something else wrong.
I'm trying to list the contents of the current directory. I don't want it to be entered already though (example of not $dir = "."
I already had a script for that which didnt work. I want the php to figure out the current directory and list the contents and then later for the user to be able to change that if they want. I got part of this from php.net .
PHP Code:
<?php
$server = $_SERVER['REQUEST_URI'];
$split_server = explode('/', $server);
unset($split_server[count($split_server)-1]);
$curdir = implode("/", $split_server);
$dir = $curdir;
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
?>
Bookmarks