Welcome visitor
* Login
* Register
It is currently July 23rd, 2019, 7:17 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Dinamically create links to all files in a directory
PostPosted: January 2nd, 2010, 7:44 pm 
User avatar

Posts: 34
Hi,

I have a site and the main page is a link to all the files I have on the server. As I add files very often I'm wondering if there would be a way to automatically create the links to each file on the folder? Or should I modify the main page each time I upload a file?


Thanks for your time.


Top
 Profile  
 
  Re: Dinamically create links to all files in a directory
PostPosted: January 3rd, 2010, 6:39 am 
User avatar

Posts: 137
You will need a server side language to find what's on the server side :P

From the PHP manual with a small variation we can get this:
<?php
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo '<a href="'.$file.'">'.$file.'</a><br />';
        }
    }
    closedir($handle);
}
?>
http://php.net/manual/en/function.readdir.php


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron