I'm creating a dynamic link to all files in a specific directory so files can just be dropped into that directory and will automatically display on the page at next reload. I have the following code:
$directory = "../pdfs/programs";
$dirHandle = opendir($directory);
echo "<a href='../pdfs/programs/January 2003.pdf'>January 2003 Program</a>";
$nCount = 0;
while ($szFileName = readdir($dirHandle) )
{
if (is_file($szFileName) )
{
$retArray[$nCount++] = $szFileName;
}
}
sort($retArray);
The $directory only works if the directory is "." If I change the directory to anything else, I get a Wrong datatype error on the sort (at the bottom) like its not getting an array. I can change to an non-existant directory and I get the non-existant directory error, so it obviously is recognizing the directory defined in $directory. Notice the echo line below uses the same path and it works just fine. Does anyone have a clue why this won't work??
This is absolutely driving me nuts. I've tried "$DOCUMENT_ROOT/pdfs/programs", "/pdfs/programs", "\pdfs\programs", "\pdfs\programs" and many combinations thereof and it does not work. I'm using windows 2000 with apache.