Show all images in a directory using PHP

This is a sweet script. It displays all the files in a particular directory. In this case it’s a folder full of user uploads, so it makes keeping an eye on things a breeze.

<?php
 foreach(glob('upl/*.*') as $file){
     echo '<img src="'.$file.'" border="0" alt="'.$file.'">';
 }
 ?>

You can of course easily modify it to show only JPGs or other image types (if you’re pulling content from a directory of mixed file types) or to edit the echo so it returns images that link to user profiles etc.

But this is it’s most basic form.