Click to See Complete Forum and Search --> : [RESOLVED] GLOB...Help Needed
robertketter
06-10-2007, 07:54 PM
$glob = glob($uploaded_dir."*.jpg");
need help, sometimes the uploaded jpg's extension is .JPG all uppercase so I need to make above code non case sensative. Thanks in advance.
Sheldon
06-10-2007, 08:09 PM
can you not strtolower() (http://php.net/sttolower) the file name when you upload the image?
FusionComputers
06-10-2007, 08:09 PM
$extension = strtolower("*.jpg");
$glob = glob("$uploaded_dir . $extension");
Maybe something like that?
Sheldon
06-10-2007, 08:10 PM
$extension = strtolower("*.jpg");
$glob = glob("$uploaded_dir . $extension");
Maybe something like that?
That wont work.
this may
$glob = glob($uploaded_dir . "*.jpg|*.JPG");
FusionComputers
06-10-2007, 08:13 PM
Haven't used the glob function yet. I tried... :p
Sheldon
06-10-2007, 08:14 PM
or
<?php
function showdir($source){
if($handle = opendir($source)){
while(false !== ($file = readdir($handle))){
if($file != "." && $file != ".."){
if(preg_match('/^(.*)(\.(?:jpg|jpeg|gif|png))$/i', $file)){
echo ("{$file} <br />"."\n");
}
}
}
closedir($handle);
echo("End of Dir");
}
}
showdir("/images/uploaded/");
?>
robertketter
06-10-2007, 08:25 PM
Thanks to all.... Sheldon is the winner this round. Your second answer is the best way I can see to do it.
PS...The images are ftp'ed automaticly late at night from my customer computers and I can't control the case of the ftp'ed files. The indexing on the websites is totally automatic. thanks again to all