opendir and readdir acting funky
Posted: Thu Jan 29, 2004 10:03 pm
Hola all, supernoob is back.
I've been banging my head against a wall trying to write a script that outputs the contents of a directory on a page. I've written it every way I know how (admittedly, that aint much). For some reason, PHP doesn't see the directory I'm trying to open (or just plainly denies its existance). The directory is there, filled to the brim with text files, whose names I want output to a page.
in case it was my meager writing skills at fault, I though I would use the code used in the manual, and I get te same results... nothing.
Is there a problem with the script?
Any help on this issue would be greatly appreciated.
I just don't get it... it should work.
I've been banging my head against a wall trying to write a script that outputs the contents of a directory on a page. I've written it every way I know how (admittedly, that aint much). For some reason, PHP doesn't see the directory I'm trying to open (or just plainly denies its existance). The directory is there, filled to the brim with text files, whose names I want output to a page.
in case it was my meager writing skills at fault, I though I would use the code used in the manual, and I get te same results... nothing.
Is there a problem with the script?
Code: Select all
$dir = '/content/';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}I just don't get it... it should work.