Displaying images from a directory...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jderosa3
Forum Newbie
Posts: 2
Joined: Thu Sep 22, 2005 9:22 pm

Displaying images from a directory...

Post by jderosa3 »

First off I am using exec-php with Wordpress to execute PHP code in my "static" pages - I assume what I want to do it simple, but I am having issues.

What I want to do is just display all the files (JPGs) from a specified directory. I coded the following:

Code: Select all

<?php
$dir = "./flash/portfolio/branding/images/";
//open dir
if ($opendir = opendir($dir))
{
   //read dir
while (($file = readdir($opendir)) !== FALSE)
{
if ($file!="."&&$file!="..")
echo $file."<img src='$dir/$file'><br />";
   }
}
?>
but... all this does is list the files names and right next to them it displays a broken icon as if the graphics are not there... what gives... can any one test this... and let me know their results... or is there another method to display graphics in this manner. :?:

Thanks!
Last edited by Benjamin on Wed Apr 29, 2009 7:33 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Displaying images from a directory...

Post by McInfo »

What is the full path to your script, and what is the full path to your images folder?

Edit: This post was recovered from search engine cache.
Post Reply