PHP Project (Simple) – Dynamic Photo Gallery Stream

Using the GLOB function in PHP you can put all of the file names on a folder, and then print them out with additional HTML to create a Dynamic Photo Stream.

In this project the PHP script will read what files are in a folder, and then print them out in IMG tags with additional CSS styling.


  • Basic LAMP, or Web Server Administration
    • Verify pictures and folder have READ permission for OTHER
  • Basic PHP
  • Basic HTML
  • Basic CSS

Glob() Function:

LAMP Server

  • Create a “pics” directory in the Public Web Directory (/var/www/html)
  • Verify pictures and folder have at least a – – r permission.


<link rel='stylesheet' href='picStyle.css' />

$filelist = glob("./pics/*");

foreach($filelist as $filename){
	echo "<div><img src='".$filename."'></div><br>";



img {
	display: block;	
	width: 50%;
	height: auto;
	margin-left: auto;
	margin-right: auto;

div {
	background: lightgrey;

div:nth-of-type(even) {
	background: grey;

1 Comment

Leave a Reply