Clan Adverts

PHP Web Host - Quality Web Hosting For All PHP Applications

 

Display all files in a directory

Description: This little script will display all files in a directory of your choice.
Version: 1.0
Added on: 03 August 2007
Author: floppy
Difficulty Level: Intermediate
Views: 1532
Rating: 10.0 (3 Votes)
Detailed ProfileView Comments (2)

With a little inspiration and creativity. You could make this script do a lot of things. Very useful if you want to display a lot of files for direct download and such.

Code:
<?
/**
* Change the path to your folder.
* This must be the full path from the root of your
* web space. If you're not sure what it is, ask your host.
*
* Name this file index.php and place in the directory.
*/
    // Define the full path to your folder from root
    $path = "/home/content/s/h/a/shaileshr21/html/download";

    // Open the folder
    $dir_handle = @opendir($path) or die("Unable to open $path");

    // Loop through the files
    while ($file = readdir($dir_handle)) {

    if($file == "." || $file == ".." || $file == "index.php" )

        continue;
        echo "<a href=\"$file\">$file</a><br />";

    }
    // Close
    closedir($dir_handle);
?>