Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search for file with either .jpg or gif extention

Status
Not open for further replies.

Screamsid

Programmer
May 14, 2003
20
GB
Hi i'm lookin for some advice on how to search for a file that has the extention of either .jpg or .gif on the server.

I'm toying in using file_exists however since i'm searching for a file that will either have the .jpg or .gif extention i'm not totally sure how to go about it. There is a naming convention set up so the name to the file doesn't matter at this particular point of time. However if the file is found it's then deleted.

Hope i explained that properly. Head feels a little swampy at the moment and being to php doesn't help, lol.

Thanks in advance
 
ok i think i've nearly sovled it myself. However i was wondering is it possible to do a search for a file with a * extention?

 
if you have > 4.30 PHP, use glob()

<?php
$ext="txt";
foreach (glob("*.".$ext) as $filename) {
echo "$filename size " . filesize($filename) . "\n";
}
?>

done from memory, cant verifiy it at the moment.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top