Why does the script hardcode the directory separator? In Windows, it's a backslash, so this code is already not portable. And the file name might need to be encoded (safe) before sending to browser. Try this instead:
define(DS, DIRECTORY_SEPARATOR) ; // ... is / on nix and \ on Windows
define(BR,'<br>') ;
$dirName = DS . 'etc';
$dir = opendir($dirName);
while ( ($file = readdir($dir)) ) {
$tempFile = $dirName . DS . $file ;
$tempFileSafe = htmlentities($tempFile, ENT_QUOTES);
if (is_dir($tempFile)) {
echo "Directory: $tempFileSafe", BR;
} elseif (is_file($tempFile)) {
echo "File: $tempFileSafe", BR;
} elseif (is_link($tempFile)) {
echo "Link: $tempFileSafe", BR;
} else {
echo "Unknown: $tempFileSafe", BR;
}
}
closedir($dir);
Chris