Code: Select all
<HTML>
<HEAD><TITLE>TEST</TITLE></HEAD>
<BODY>
<?php
$address = $_GET['wb'];
if($dire = opendir($address));
{
print("Directory name: $address<BR>\n");
while(false !== ($file=readdir($dire)) );
{
print("$file<BR>\n");
}
closedir($dire)
}
?>
</BODY>
</HTML>http://www.eng.umd.edu/enme331/wpc.html
It seems that the directory is valid because the code goes through the opendir statement and prints the directory name. It also seems to go into the while loop once because there are two <BR> printed. However the $file variable obtained from the readdir is empty.
I have checked two things:
1. The local (.) directory itself contains about 8 files and in the directory all the files have read permissions (-rw-r--r--)
2. The server allows directory reading (allow_url_fopen is ON, http://www.eng.umd.edu/enme331/info.php)
Any idea why I cannot read the contents of a directory? What am I doing wrong?
Thank you,
Nikolaos