showing images from a folder

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
ultimachris
Forum Newbie
Posts: 1
Joined: Mon Apr 20, 2009 4:58 am

showing images from a folder

Post by ultimachris »

Hi there, i know this is fairly simple, i have a folder where images get uploaded too but i want to create a php fileto show the array of images from this folder, its a simple web folder and all the images are jpg or gif.
Hope you experts could point me in the right direction!! :)
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: showing images from a folder

Post by novice4eva »

Code: Select all

 
                $fileNames = array();//this will hold all the file names
        if ($handle = opendir($dirPath)) //$dirPath is path of folder where your images are stored
        {
            while (false !== ($file = readdir($handle))) 
            {
                if ($file != "." && $file != "..") //add conditions for gif/jpg ..
                    array_push($fileNames,$file));
            }
            closedir($handle);
        }
 
Last edited by Benjamin on Fri Apr 24, 2009 10:07 pm, edited 1 time in total.
Reason: Changed code type from text to php
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: showing images from a folder

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply