Publishing System Settings Logout Login Register
Show images in directory
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on May 26th, 2007
857 views
PHP Coding
Copy this code and paste it ino a new file called index.php. Put index.php in the directory you want listed. Upload it to your webserver and see your files in www.yoursite.com/whatever/index.php


<?php
$ext_arr = array("jpg","png","gif");
$ext = $_GET['ext'];
$handle=opendir('.');

if(!isset($ext))
{
    $strSought = "jpg";
}
else
{
    if(in_array($ext, $ext_arr))
    {
        $strSought = $ext;
    }
    else
    {
        $strSought = "jpg";
    }
}

$num = 0;

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

closedir($handle);
$handle=opendir('.');

echo "There are $num $strSought files!<br /><br />";
echo "<ul>nt";

foreach($ext_arr as $key)
{
    echo("<li><a href="".$_SERVER['PHP_SELF']."?ext=$key">$key</a></li>nt");
}

echo "</ul>";
echo"<table>";
echo "<tr>nt<th>Files:</th>nt<th>Width</th>nt<th> </th>nt<th>Height</th>nt<th>Size</th>n</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>";
?>
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send


This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top