|
|
|
|
![]() ![]() |
Mar 6 2005, 08:42 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 218 Joined: 13-January 05 Member No.: 3,267 |
is there a php function that lists the content of some folder....
example: /New folder new.txt left.gif download.zip dc.exe ....so is there..? |
|
|
|
Mar 6 2005, 12:44 PM
Post
#2
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 524 Joined: 6-March 05 Member No.: 4,187 |
I have no clue. I think there might be but I dunno. There is something where you can register and the info goes to a folder. But I dunno.
|
|
|
|
Mar 6 2005, 01:49 PM
Post
#3
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 12 Joined: 6-March 05 Member No.: 4,196 |
best thing would be to Google it!
Try something like 'Advanced PHP Tutorials' Cheers! Yasir |
|
|
|
Mar 6 2005, 02:14 PM
Post
#4
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 362 Joined: 2-March 05 From: The Netherlands Member No.: 4,097 |
I don't think theres a pre-programmed function for that, you could, of course do it manually, updating it manually when your folder has new content:
CODE <?php $folder_content = 'echo "The following files are content of the selected folder:" echo "$list"'; $list= "new.txt, left.gif, download.zip, dc.exe"; echo "$folder_content"; ?> You could put that in a new file called "folder_content.php" and then (for example in your indexpage, put the following line: include("folder_content.php"); That way you can easily edit the content it should display manually, while using minimum bytes for your indexpage. Hope that works for you (im just a newbie phper |
|
|
|
Mar 6 2005, 03:13 PM
Post
#5
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 378 Joined: 8-January 05 Member No.: 3,174 |
QUOTE(Corey @ Mar 6 2005, 09:42 AM) is there a php function that lists the content of some folder.... There is opendir() which you can use to open a dir and then loop through the contents. CODE <?php if ($handle = opendir("yourdirhere")) { while (($file = readdir($handle)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; } closedir($dh); } ?> Note that this will also list sub-directories and '.' and '..'. You can get info in the php.net documentation for opendir(). |
|
|
|
Mar 7 2005, 11:39 AM
Post
#6
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 113 Joined: 14-January 05 From: Philippines Member No.: 3,271 |
i came up with this. it is similar with bjrn's but will sort all folder and files alphabetically. also will be conatined in a multi-dimensional array together with their name and statistics.
CODE $directory = "path/to/dir"; while (($item = $directory->read()) !== false) { if ($item != "." && $item != "..") { $path = "{$directory->path}/{$item}"; if (is_dir($path)) { $tmp['name'] = $item; $tmp['stats'] = lstat($path); $dirs[$item] = $tmp; unset($tmp); } elseif (is_file($path)) { $tmp['name'] = $item; $tmp['stats'] = lstat($path); $tmp['extension'] = substr($item, strrpos($item, ".")); $files[] = $tmp; unset($tmp); } } } ksort($dirs, SORT_STRING); sort($dirs); ksort($files, SORT_STRING); sort($files); |
|
|
|
May 13 2008, 06:23 AM
Post
#7
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
Good Php Directory
Getting List Of Directories And Files Using Php Here is a good PR4 Php directory Www.Businessservicesuk.Com -reply by Pete |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 25th July 2008 - 08:40 PM |