can't read a file in a dir, why?
Posted: Wed May 28, 2003 10:41 am
This code works fine and populates my <option> BUT when I added a file called wellpath.gif it will not read it. if I drop the W (ellpath.gif) no problem, if I change the W to anything EXCEPT v,w,x,y,z again no problem. If I change it to the above letters it wont list. Wassup?
Thank you to all who can shed some light.
SilvrWolf
Thank you to all who can shed some light.
SilvrWolf
Code: Select all
<?php
//Insurance Image
//ins_image_array gets an array of images from the image directory
$path = "../images/";
if ($dir = opendir($path)) {
while($file = readdir($dir)) {
if ($file != "." && $file != ".." && substr($file, -3) == "gif" || substr($file, -3) =="jpg"){
$ins_image_array[] = $file;
}
}
closedir($dir);
}
// create a drop-down with the file names in the image directory
// use the image_dir_arry to populate the drop down
// use logic to select the image file name and place SELECTED in its option tag
for ($i=0; $i<count($ins_image_array)-1; $i++){
echo "<option value="".$ins_image_array[$i].""";
if ($ins_image_array[$i]=="no_image.gif"){
echo "SELECTED";
}
echo ">".substr($ins_image_array[$i], 0, -4)."</option>\n";
}
?>