Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question a script to fill a page with links to all the files in the folder

    Is there a script that will automatically fill a webpage with links to all of the files in its web directory (except for itself)? It would sure be handy so all the resources (regardless of how the content changes) in a folder can be easily accessed.

    Appreciate anything the geniuses can come up with!

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,149
    Thanks
    2
    Thanked 333 Times in 325 Posts
    Because javascript does not have direct access to or have the ability to do a directly listing of files on a web server, you need to do this using a server side scripting language (PHP/ASP/ASP.NET...)
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh. :-( Any suggestions on how I would do this with PHP then?

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by CFMaBiSmAd View Post
    Because javascript does not have direct access to or have the ability to do a directly listing of files on a web server, you need to do this using a server side scripting language (PHP/ASP/ASP.NET...)
    Not entirely correct.

    If you configure your server to allow the folder listing access (on apache it is as simple as adding the following line to .htaccess: "Options +Indexes +MultiViews +FollowSymlinks"), you can use the XMLHTTPRequest to get the html file returned by the server and then parse it to extract desired file information.
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #5
    New Coder
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know if it will be of use in your case, but I've written a few websites which use a PHP script to list the contents of a folder as active links. I use the following code in a file called index.php, and put it into the folder in question. Here's the code:

    Code:
    <html>
    <head>
    </head>
    <body>
    <?
    
    //define the path as relative
    $path = ".";
    
    //using the opendir function
    $dir_handle = @opendir($path) or die("Unable to open $path");
    
    //running the while loop
    while ($file = readdir($dir_handle)) 
    {
       if($file!="." && $file!=".." && $file!="index.php")
          echo "<a href='$file'>$file</a><br/>";
    }
    
    //closing the directory
    closedir($dir_handle);
    
    ?> 
    </body>
    </html>

  • #6
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm, that looks like it might work!

    thanks!!

  • #7
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    works like a charm!!! :-)


  •  

    Posting Permissions

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