I have a bunch of pics from my digital camera, being lazy I do not really want to edit the page with new code every time I press the button.
Anyone got some PHP that Linux likes to scan for pics and makes a bunch of thumbnails and links to the full picture?
Showing pics from a camera
Moderator: General Moderators
Showing pics from a camera
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
-
schwarzerosen
- Forum Newbie
- Posts: 3
- Joined: Fri Jun 26, 2009 10:45 pm
Re: Showing pics from a camera
Code: Select all
<?php
//getting all files of desired extension from the dir using explode
$desired_extension = 'gif'; //extension we're looking for
$dirname = "images/";
$dir = opendir($dirname);
echo '<html><body>';
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != ".."))
{
$fileChunks = explode(".", $file);
if($fileChunks[1] == $desired_extension) //interested in second chunk only
{
echo '<a href="images/'.$file.'" target="_blank"><img src="'.$file.'""></a></br>';
}
}
}
echo '</body></html>';
closedir($dir);
?>
Re: Showing pics from a camera
Thanks, I am implementing the code in a slightly different way. I carved it up into segments so that I could bolt in into an existing page template. The code example however is ideal for a basic understanding of the code required to generate a page of images from a given folder where the page actually looks for them and display any found automatically.
Thanks as this is very helpful.
Thanks as this is very helpful.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP