Newbie Help, take pitty please. (getimagesize + readdir)
Posted: Mon Oct 03, 2005 2:08 pm
Below is my first Php effort, I know its full of errors and I hope someone can help. I want to print out through PHP an XML file to read into my Flash document. I want to get the file names in a specific directory, which I have done successfully using "readdir". I'm trying to use unsuccessfully "getimagesize" in the same "while" loop to return the width of the images.
My Xml file produced from the Php script, has this error included for each file in the directory and the width value is blank.

Code: Select all
<?php
echo "<?xml version=\"1.0\" encoding =\"ISO-8859-1\" ?>\n";
echo "<images>\n";
if ($handle = opendir('images')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$width = getimagesize($file);
echo "<myImage Path=\"images/" . "$file\"" . " Width=\"" . "$width\"" . " />\n";
}
}
closedir($handle);
}
echo "</images>\n"
?>Code: Select all
<br />
<b>Warning</b>: getimagesize(1.jpg): failed to open stream: No such file or directory in <b>/home/1/k/kjellman/Temp/imageList.php</b> on line <b>7</b><br />
<myImage Path="images/1.jpg" Width="" />