Skipjackrick Posted February 22, 2008 Share Posted February 22, 2008 I am having a problem with this script. Is it possible to only allow .jpg or images. It is grabbing my php files too. I think the problem is in this small snippet of code below. example link http://www.ectackle.com/uploader/uploaded_files/teampage.php <?php if ($handle = opendir('/home/ectackle/public_html/uploader/uploaded_files/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<a href='$file' onclick='return hs.expand(this)' class='highslide'> <img src='show_image.php?filename=$file&width=100&height=100' alt=''/> </a> "; } } closedir($handle); } ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 22, 2008 Share Posted February 22, 2008 <?php if ($handle = opendir('/home/ectackle/public_html/uploader/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...
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.