Page 1 of 1
Directory's Content
Posted: Sat Jan 08, 2005 1:26 pm
by Tempest
I was just wondering if there was a way i could list all the files not including the folders on a page?
Posted: Sat Jan 08, 2005 1:34 pm
by feyd
[php_man]glob()[/php_man] or [php_man]opendir()[/php_man]
Posted: Sat Jan 08, 2005 1:41 pm
by Tempest
hehe see im realy new to php how exactly would i use that?
Posted: Sat Jan 08, 2005 1:44 pm
by John Cartwright
Have you visited the links?
Try it out, post what you came up with.
Posted: Sat Jan 08, 2005 1:46 pm
by Tempest
i read the pages but i come out with errors i tried using glob but it didn't work :\
can you give me an example cause the example on the site didn't help
Posted: Sat Jan 08, 2005 1:49 pm
by feyd
glob() is only available in more recent versions of php (newer than 4.3.0). You may have an older version. Try the examples on opendir()'s page.
Posted: Sat Jan 08, 2005 1:55 pm
by Tempest
Code: Select all
$dir = "/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file<br>";
}
closedir($dh);
}
}
i have that but its showing files that are not even in the directory that the file is in
NVM i fixed that thanks for all your help
feyd | Help us, help you. Please use Code: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]