images..
Moderator: General Moderators
images..
Hi, here is my problem,, I have a directory where all uploaded images go, and basically I want a page which just loops over the dir getting all images from it, and just dumping them on the screen is that poss? if so can anyone give any pointers as to how? thanks very much,,
This should do it (untested)
Code: Select all
$fs_path = '/absolute/path/to/images';
$web_path='/web/accessible/path/to/images';
chdir($fs_path);
$files = glob('*');
foreach($files as $filename)
{
echo "<img src = '$web_path/$filename' />";
}Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
Code: Select all
$fs_path = '/absolute/path/to/images';
$web_path='/web/accessible/path/to/images';
chdir($fs_path);
$files = glob('*');
foreach($files as $filename)
{
if (!in_array($filename,array('.','..'))) { // <-- to exclude unwanted items
echo "<img src = '$web_path/$filename' />";
}
}