Hello guys,
I'm wondering how to display the file names (and possibly generating links to them) in a folder using php.
What I'm trying to do here is to allow people to upload some pictures onto my server and also be able to generate the latest list. I'm trying to avoid using database as I don't see the need to go to that extent.
So, I'm wondering if php can return the file names. Thanks!!
cj2000
Using php to display the file names within a folder
Moderator: General Moderators
Code: Select all
<?php
$folder = "delta\gaming\gaming\gallery_files";
/* no need to edit the settings below */
if($handle = opendir($folder))
{
while($files = readdir($handle))
{
if ($files != "."
&& $files != "..")
{
echo '<a href="'.$folder.'/'.$files.'">'.$files.'</a> '."<br>\n";
}
}
}
?>there u go...this will list all files in the a folder so either u should only put images in there or edit this script to allow only images to be showen