...

View Full Version : get all files in a folder and list them



ripken204
01-08-2007, 03:57 AM
im not shure if there is another easier way to do this without php.. anyways,

i have a bunch of files in a folder and i want a script that will scan the folder and display all of the files in that folder, then display all of those files in an html document so that i can download whatever file i want.

whizard
01-08-2007, 04:01 AM
$skip_folders = array('.','..','ANY OTHER FILES/FOLDERS YOU WANT SCRIPT TO HIDE');
$dir = /*PATH TO DIRECTORY*/
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if(!in_array($file, $skip_folders))
{
print("<li><a href=\"$file\">$file</a></li>");
}
}
}
closedir($dh);
}

I forgot to do this last night, but for valid and working HTML, you should put <ul> and </ul> tags around the script. Sorry for leaving that out

HTH,
Dan

ripken204
01-08-2007, 04:19 AM
thank you very much

whizard
01-08-2007, 04:43 PM
No Problem!!

:)

Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum