View Full Version : automatically update links to files in specific folder
rinkguy
07-17-2005, 03:10 PM
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
I would like to acomplish this with simple html if possible
It's not.
The PHP code you want is:
<?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.
rinkguy
07-18-2005, 05:06 AM
thanks, That worked like a charm :D
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.