Jump to content

Only get images???


Skipjackrick

Recommended Posts

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

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.