Posted by Aquosus on 10/06/06 05:05
I am trying to load all the images from the Images directory. There are
about six sub_Directories in the Images directory. Some of the Sub_Dir have
Subs themselves.
I have tried to write the following but it seems to not work at all.
I know there must be a simple way to do this and I don't feel like
re-inventing the wheel. Could someone show me some code that will read the
directory and its Sub_Directories seeking for all JPEGs.
Thanks
//Snippet
$dir = "/Images/";
$myDirArray=array();
if(is_dir($dir))
{
if($dh=opendir($dir))
{
while(($file=readdir($dh))!==false)
{
$tmpDir=$dir . $file;
if(is_dir($tmpDir))
{
if($myDir=opendir($tmpDir))
{
while($myFile=readdir($myDir))
{
array_push($myDirArray, $tmpDir.$myFile);
}//while($myFile=readdir($myDir))
closedir($myDir);
}//if($myDir=opendir($tmpDir))
}//if(is_dir($tmpDir))
}//while(($file=readdir($dh))!==false)
closedir($dh);
}//if($dh=opendir($dir))
for($x=0;$x<sizeof($myDirArray);$x++)
{
echo "Corrected filename: $myDirArray[$x] <BR />\n<BR />\n";
}//for($x=0;$x<sizeof($myDirArray);$x++)
}//if(is_dir($dir))
end Snippet//
--
Totus possum, totum Deum.
Totus ero, totum meum.
WSW
Navigation:
[Reply to this message]
|