I tried loading the names of the files in the Books directory, with the following code:
<?php
if ($handle = opendir('/Books')) {
echo "Directory handle: $handle
";
echo "Entries:
";
while (false !== ($entry = readdir($handle))) {
echo "$entry
";
}
closedir($handle);
}
?>
But it seems not to display the names. Am I doing this wrong or not locating the right directory?
Seems as if you're using the wrong directory... I think the Books
folder is in the same directory as your script?
Then use only opendir('Books')
which is a relative path to the directory.
When you use /Books
you use the Books
folder located in the root directory of your filesystem. (this is called an absolute path)
I guess I would use scandir()
for this one:
<?php
$scanner = scandir("theFolder");
foreach ($scanner as $fileName) {
echo "$fileName<br>";
}
?>