Advanced Search

Results 1 to 3 of 3

Thread: automatically update links to files in specific folder

  1. #1
    Join Date
    Jul 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default automatically update links to files in specific folder

    I run a webserver on my home PC, I would like to know (if it's Possible) how I can make a personalized home page (index.html) that will update itself with links to files in a specified folder. E.g. If I copy an new file or remove a file from a download folder I would like the index.html to automatically detect the changes and update the links automatically. I would like to acomplish this with simple html if possible as I don't understand .php and well any other formats to tell the truth.

    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I would like to acomplish this with simple html if possible
    It's not.
    The PHP code you want is:
    PHP Code:
    <?php
    $dirname 
    '/var/www/download_folder'// adjust as needed, such as 'C:\web_root\download_folder' for Windows
    $webdirname '/download_folder'// what the directory appears as from the web browser's point of view

    $dir opendir($dirname);
    $file_list '';

    while((
    $file readdir($dir)) != false) {
    if((
    $file != '.') && ($file != '..')) {
    $file_list .= "<a href=\"$webdirname/$file\">$file</a><br/>";
    }
    }

    closedir($dir);
    ?>

    <p>
    <?=$file_list?>
    </p>
    That should list all the files in $dirname as links to them.
    You will, as ever, need PHP installed on your webserver. Downloads and instructions on php.net.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks, That worked like a charm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •