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); } ?> Link to comment https://forums.phpfreaks.com/topic/92405-only-get-images/ 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); } ?> Link to comment https://forums.phpfreaks.com/topic/92405-only-get-images/#findComment-473438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.