Jump to content

pictures


yoshida

Recommended Posts

Heya.Is there a way to make php generate a page with pictures? Let's say you echo an article named 20060626 (date formatted as yyyy/mm/dd so all articles can be sorted by date no mather what). There's also a folder on the same server named 20060626, which contains pictures. Is it possible for a php script to generate a 'photo album' once it knows where the pictures can be found?First of all, the script should know where those pictures are. Not too difficult, since the folder has the same name as the article id. Then the script needs to check if there's actually jpeg files in that folder, how many there are and how they're called. At least that's what I'm thinking.Any ideas? I wouldn't mind using js, tho I'd like to avoid using too much of it.

Link to comment
Share on other sites

How to do it. I can see logically what should happen, but I don't know how to make it work.For instance: what command makes a php script scan for pictures on a specific location? And with what command can I get them to show on a page? I simply want to know if it can be done, and if yes how.

Link to comment
Share on other sites

Can't write for you whole scripts, I can only show you some things to inspire from.http://www.php.net/manual/en/function.opendir.phpSee the first example how to open and parse a directory to look for the files. You may check $file to see if it contains the .jpg extension (or whatever extensions your images will use) to identify the image files ($file is a string, so you can use http://www.php.net/manual/en/function.strripos.php for example, just check if it returns true or false).Images are shown in the browser just echoing the HTML:$folder = '20060626';echo '<img src="'.$folder.'/'.$file.'">';Of course the path must be relative to the script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...