Showing All Images In Folder
Moderator: General Moderators
-
CoolAsCarlito
- Forum Contributor
- Posts: 192
- Joined: Sat May 31, 2008 3:27 pm
- Contact:
Showing All Images In Folder
Okay I want my photos.php file to show all the photos I have in my /kowphotos/ folder on my server. How do I go out having that done?
-
CoolAsCarlito
- Forum Contributor
- Posts: 192
- Joined: Sat May 31, 2008 3:27 pm
- Contact:
Re: Showing All Images In Folder
The only thing is I don't want my images listed. I actually want them shown.
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: Showing All Images In Folder
Pause between firing rounds.CoolAsCarlito wrote:The only thing is I don't want my images listed. I actually want them shown.
Re-read that link that califdon post and try to think of a clever way to use that returned information to solve your problem.
Code: Select all
<?php
$path_to_images = 'images/';
$images = scandir($path_to_images);
foreach($images as $image)
{
print '<img src="' . $path_to_images . $image . '" />';
}
?>-
CoolAsCarlito
- Forum Contributor
- Posts: 192
- Joined: Sat May 31, 2008 3:27 pm
- Contact:
Re: Showing All Images In Folder
Code: Select all
<?php
$path_to_images = 'images/kowphotos';
$images = scandir($path_to_images);
foreach($images as $image)
{
print '<img src="' . $path_to_images . $image . '" />';
}
?>
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: Showing All Images In Folder
A forward slash in your $path_to_images variable (at the end).CoolAsCarlito wrote:What am I missing?
-
CoolAsCarlito
- Forum Contributor
- Posts: 192
- Joined: Sat May 31, 2008 3:27 pm
- Contact:
Re: Showing All Images In Folder
Okay I did that but what does this error mean?
Fatal error: Call to undefined function: scandir() in /home/content/y/a/n/yankeefaninkc/html/kowphotos2.php on line 3
Fatal error: Call to undefined function: scandir() in /home/content/y/a/n/yankeefaninkc/html/kowphotos2.php on line 3
Re: Showing All Images In Folder
that means you don't have php 5...
you can use system directive, and you should make a simple recruisive algorithm to scan subfolders....
this is solution for linux/unix operatin systems....
you can use system directive, and you should make a simple recruisive algorithm to scan subfolders....
this is solution for linux/unix operatin systems....
Code: Select all
function rek ($path) {
$output = system ("ls -1 $path", $status);
//if failed to run above command (probebly premission denied)
if ($status != 0) return;
$ls = split ("\n", $output);
foreach ($ls as $file) {
// if "file" is a directory
if ((int) system("file ${path}/${file} | grep 'directory' | wc -l") == 1)
rek ("${path}/${file}");
else if ((int) system("file ${path}/${file} | grep 'image' | wc -l") == 1)
echo "<img src='${path}/${file}' />";
}
}
//you call function using:
rek ("path/to/images/folder");
-
nowaydown1
- Forum Contributor
- Posts: 169
- Joined: Sun Apr 27, 2008 1:22 am
Re: Showing All Images In Folder
I believe that glob (http://us3.php.net/glob) is also available on PHP 4.