Skipjackrick Posted February 29, 2008 Share Posted February 29, 2008 I am having problems with the following script. It only allows me to display images that are ".jpg" format. Sometimes the image might have the extension ".JPG" or ".gif" or ".GIF" or ."png" or ".PNG" How can I change the following script to accept the other file extensions? I tried altering this tiny snippet but I kept getting parse errors. if (preg_match('/\.jpg$/', $file)) { HELP ME PLEASE!!! Thanks. <?php if ($handle = opendir('/home/extremecoast/public_html/Kayak_Wars/Team_Original/uploaded_files/')) { while (false !== ($file = readdir($handle))) { if (preg_match('/\.jpg$/', $file)) { echo "<a href='$file' onclick='return hs.expand(this)' class='highslide'>\n"; echo "<img src='show_image.php?filename=$file&width=100&height=100' alt=''/>\n"; echo "</a>\n"; } } closedir($handle); } ?> Quote Link to comment Share on other sites More sharing options...
blackwinter Posted February 29, 2008 Share Posted February 29, 2008 if (preg_match("/(\.jpg|\.png|\.gif|\.jpeg)$/s", $file)) { Quote Link to comment Share on other sites More sharing options...
tinker Posted February 29, 2008 Share Posted February 29, 2008 Just because i'm watching the weakest link: if (preg_match("/\.(jpg|png|gif|jpeg)$/i", $file)) { not sure if i'm right but i've changed the 's' to an 'i', ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.