How do I create an html list from list of files?

Posted on 2014-08-20
Last Modified: 2014-08-27
I would like to create an html web page which looks in a specific directory and then lists the names of the files, as a link, to the files in that directory.  This is for an intranet purpose.

ie. Folder1 has 10 files, all pdf files with various names.  I want to create a web page for the intranet, which lists all those 10 files, and if you click on the name of the file then it will open the pdf files.
Question by:100questions
    LVL 6

    Expert Comment

    by:Tim Phillips
    This software looks like it will do what you want:
    LVL 11

    Expert Comment

    Here's one I wrote way back in 2008... it is very simple but effective and each file or directory is a link that you can click on to open. I use it as the index for my WIP directory so any file or mini-app can be opened with a single click and without having to remember all the paths to type in the browser URL.

    It is PHP but the same principle applies for other languages
    echo"<title>File List</title>";
    echo"<style type=\"text/css\">";
    echo"body,td,th {";
    echo"font-family: Verdana, Arial, Helvetica, sans-serif;";
    echo"font-size: 11px;";
    echo"color: #333333;";
    echo "<h2>Files/Directories</h2>";
    echo "This folder contains:<br /><br />";
    $dir = opendir(getcwd());
    while (false !== ($file = readdir($dir)))
    	if(true == is_dir($file)&&$file!=="."&&$file!==".."&&$file!=="phpmyadmin"&&$file!=="signoff"&&$file!=="internal")
    	echo "<li>&lt;dir&gt;&nbsp;<a href=\"$file\">$file</a></li>";
    $dir = opendir(getcwd());
    while (false !== ($file = readdir($dir)))
    	if(false == is_dir($file)&&$file!=="."&&$file!==".."&&$file!==".htaccess"&&$file!==".htpasswd"&&$file!==".bash_history"&&$file!=="index.php"&&$file!=="index.php.bak")
    		echo "<li>file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"$file\">$file</a> ".round(filesize($file)/1000)."kb</li>";

    Open in new window


    Accepted Solution

    One can use ARCLab Dir2 HTML software.

    Author Closing Comment

    This works.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
    The viewer will learn how to count occurrences of each item in an array.

    759 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

    8 Experts available now in Live!

    Get 1:1 Help Now