PHP script to generate file index when "IndexIgnore *" set on directory

Posted on 2005-04-29
Last Modified: 2012-05-05
When a host sets either

IndexIgnore *
Options -Indexes

Is there a PHP script that can generate a list of all the files in the current directory and output them as "clickable" links?

Question by:paradoxloss
    LVL 6

    Accepted Solution

    // open this directory
          $myDirectory = opendir(".");

          // get each entry
          while($entryName = readdir($myDirectory))
                $dirArray[] = $entryName;
          // close directory

    //      count elements in array
    $indexCount      = count($dirArray);
    Print ("$indexCount files<br>\n");
    // sort 'em
    // print 'em
    print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");

    for($index=0; $index< $indexCount; $index++)
          print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");



    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now