Scan images inside folder with PHP


</pre>
<?php
 $image_path = 'images/';
 $tch = '';
 if(is_dir($image_path))
 {
 $siteurl = 'http://example.com';
 if (substr($siteurl , -1) !== '/')
 {
 $siteurl = $siteurl ."/";
 }
 $tch_dirhandle = opendir($image_path);
 while ($tch_file = readdir($tch_dirhandle))
 {
 $tch_file_nocaps = $tch_file;
 $tch_file = strtoupper($tch_file);
 if(!is_dir($tch_file) && ((strpos($tch_file, '.JPG')>0) or (strpos($tch_file, '.GIF')>0) or (strpos($tch_file, '.PNG')>0) or (strpos($tch_file, '.JPEG')>0)))
 {
 echo "<a href='".$siteurl . $image_path . $tch_file_nocaps."' rel='lightbox'>";
 echo "<img class='siteimg' src='".$siteurl . $image_path . $tch_file_nocaps."' /></a>";
 }
 }
 }
 ?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s