web_master Posted July 14, 2008 Share Posted July 14, 2008 hi, I want to reload the picture, but, what if I don't know the extension? example: if in folder is a files like 1_mainphoto_th.jpg 2_mainphoto_th.gif 3_mainphoto_th.png <?php $photo_dest = "./up_main/".$request['main_id']."_mainphoto_th" ???? ?> thnxs Link to comment https://forums.phpfreaks.com/topic/114607-picture-extension/ Share on other sites More sharing options...
tibberous Posted July 14, 2008 Share Posted July 14, 2008 Why wouldn't you know the extension? You could just do something like: $exts = array('jpg', 'png', 'jpeg', 'gif', 'bmp'); foreach($exts as $ext) if(file_exists("./up_main/".$request['main_id']."_mainphoto_th".$ext)) { $photo_dest = "./up_main/".$request['main_id']."_mainphoto_th".$ext; break; } Thats about all you can do, since yout not trying to figure out the file type, you are trying to guess the file name. Link to comment https://forums.phpfreaks.com/topic/114607-picture-extension/#findComment-589301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.