Forum Moderators: coopster

Message Too Old, No Replies

Getting and using contents in a folder

for Photo gallery with PHP

         

Darkelve

11:17 am on Aug 30, 2006 (gmt 0)

10+ Year Member



I want to make a photogallery/slideshow with PHP...

The 'gallery/slideshow' would show up inside a new window.
basically, I just want links with possibility to go:
- forward
- back
- to the very beginning
- to the very end
- away (close the window)

Can I use PHP to determine the contents of the folder with the pictures and then use variables to determine which photo to show, and what URL's should be generates for the arrows? So each folder with a series of photographs would have one PHP file and the pictures themselves in them (it's not a problem to rename them).

Should be simple enough, but I'm just starting out with PHP, and I'd like to have something working as soon as possible... the website I'm working on is about to launch soon (my first 'commercial' web project :) ), and this is about the only thing left that I still have to sort out how to do...

[edited by: Darkelve at 11:18 am (utc) on Aug. 30, 2006]

henry0

11:34 am on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should first
Set up a table in your DB
With img_id and at least img_url where the the URL to the uploaded pic will be inserted

It is better to load an image address rather loading the img as a blob.

The rest is pretty much navigation and pagination

Check for those terms there are tons of demo and tutorial

Also for img size, name etc look at
GD [us2.php.net]

omoutop

1:23 pm on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just an idea...

Get all contest of the images in folder in an array.
Then use the current(), prev(), next() functions.
Use the count() to find the number of elements in the array.
If for example there are 15 elements,
array[0] is the first
array[14] is the last.

Hope this helps

Psychopsia

1:43 pm on Aug 30, 2006 (gmt 0)

10+ Year Member



Hi!
This code reads the directory contents, search only JPG, GIF, BMP, PNG and save it in array:


$dir = '/path/images/';
$fp = @opendir($dir);

$images = array();
while ($file = @readdir($fp))
{
if (preg_match('#(.*?)\.(jpg¦gif¦png¦bmp)#is', $file))
{
$images[] = $file;
}
}
@closedir($fp);

:D

[edited by: Psychopsia at 1:44 pm (utc) on Aug. 30, 2006]

Darkelve

8:37 am on Sep 4, 2006 (gmt 0)

10+ Year Member



Psychopsia: thanks! Just what I was looking for! :D