![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Programming tutorials All Knowledge Info and links to posted here |
![]() |
|
PHP: Display a customizeable list of files in a directory
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Administrator
Posts: 18,715
Join Date: Jan 2006
Rep Power: 10
IM:
|
<!-- google_ad_section_start --> <!-- ALL ADSENSE ADS DISABLED --> Apache gives you a list of files in an empty directory by default, but sometimes you will want to show a list of files that are in a directory through PHP so that you can customize the output of the list, and make a pretty listing of files. Heres the basic code to make a list. <?php if ($handle = opendir(.)) { while (false !== ($file = readdir($handle))) { if ($file != . && $file != ..) { $thelist .= <a href=.$file.>.$file.</a>; } } closedir($handle); } ?> <P>List of files:</p> <P><?=$thelist?></p></pre> Thats about all you need to do. You could also put the list of files into an array if you felt like it, or use this as the beginning for a thumbnail page, which is what I used it for. |
|
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| List of files that exclude some files | Anilrgowda | Linux and Unix Error ! | 1 | 29-Nov-2007 03:05 AM |
| Get Back Links: Large FREE Directory List | Anilrgowda | Search Engine Optimization | 1 | 13-Apr-2007 02:53 AM |
| Updating Directory List | Iphone | Directories | 0 | 29-Mar-2007 11:14 PM |
| Free General Directory List | Anilrgowda | Directories | 2 | 22-Dec-2006 04:06 AM |
| List of 17 Free General Directory - Fast Approval | Anilrgowda | Directories | 0 | 10-Dec-2006 09:07 AM |