PhpSnip.com

User Stats

list and link to all images, and include all their information

This code allows you to dynamically list a directory's image files, creates links to them, and tells you their size in pixels and kilobytes.

Info

 Download  View Source (print view)
 Rating : 4.7  Views : 142

Source Code ( 29 lines )

<?php
    $handle=opendir('.');
    $strSought = "JPG";
    $num = 0; 


    while ($file = readdir($handle)) {
	if ($strSought == substr($file, -3)) {
		$num = $num + 1;
	}
    }
    closedir($handle); 

    $handle=opendir('.');
    echo "There are $num files!<br><br>";

    echo"<table>";
    echo "<tr><td colspan = 5>Files:</td></tr>"; 

    while ($file = readdir($handle)) {
	if ($strSought == substr($file, -3)) {
		$size = GetImageSize($file);
		$fullsize = intval(filesize($file)*.001);
        	echo "<tr><td><a href=$file>$file</a></td><td>  <b>$size[0]</b></td><td> by</td><td> <b>$size[1]</b>:</td><td> $fullsize kb</td></tr>";
        }
    }
    closedir($handle);
    echo"</table>";
?>

Search

Subscribe

  Rss Feeds

Sponsors

Advertise