+ Post New Thread
Results 1 to 7 of 7
Web Development Thread, Reading folder content into a browser in Coding and Web Development; Hi all hope you can help I'm wanting to read content from a folder and display this on a webpage. ...
  1. #1
    Fontayne56's Avatar
    Join Date
    Dec 2008
    Posts
    130
    Thank Post
    17
    Thanked 5 Times in 4 Posts
    Rep Power
    13

    Reading folder content into a browser

    Hi all hope you can help

    I'm wanting to read content from a folder and display this on a webpage. Thus when we have letters home ect parents are able to download them !! and dont need to keep updating the website.

    I use to do this on my old school webpage but for the life of me could'nt work out how i done it.

    Any ideas

    Thank You !!

  2. #2

    Join Date
    Apr 2006
    Posts
    389
    Thank Post
    23
    Thanked 95 Times in 61 Posts
    Rep Power
    45
    Hi

    Are you talking about directory browsing, e.g.

    IIS Directory Browsing

  3. #3

    Join Date
    Jan 2008
    Location
    UK
    Posts
    78
    Thank Post
    5
    Thanked 6 Times in 6 Posts
    Rep Power
    15
    If you've got PHP available on your web server, just bung this into an index.php file:

    PHP Code:
            <?php
                 $path 
    "./";
                 
    $dir_handle = @opendir($path) or die("Unable to open $path");
                  while (
    false !== ($file readdir($dir_handle))) {
                if(
    $file == "index.php")
                continue;
                echo 
    "<a href=\"$file\">$file</a><br />"; }
                
    closedir($dir_handle);
                
    ?>
    Will list everything in that directory (except the index.php file) and create a link to it

  4. Thanks to tomdawson from:

    Fontayne56 (13th May 2009)

  5. #4
    Fontayne56's Avatar
    Join Date
    Dec 2008
    Posts
    130
    Thank Post
    17
    Thanked 5 Times in 4 Posts
    Rep Power
    13
    This Worked a treat. Stick it with a style sheet bobs your uncle !!

    THANKS A BUNCH !! he he ! (one happy man)

  6. #5

    Join Date
    Jan 2008
    Location
    UK
    Posts
    78
    Thank Post
    5
    Thanked 6 Times in 6 Posts
    Rep Power
    15
    Quote Originally Posted by ryaneveritt View Post
    This Worked a treat. Stick it with a style sheet bobs your uncle !!

    THANKS A BUNCH !! he he ! (one happy man)
    Hehe, glad I could be of assistance!

  7. #6
    Fontayne56's Avatar
    Join Date
    Dec 2008
    Posts
    130
    Thank Post
    17
    Thanked 5 Times in 4 Posts
    Rep Power
    13
    Been having another play and now i would like to read a different folder where the php page does'nt sit.

    I can get them to list contence of another folder but i can seem to get the folder name into the url so the file will open. Elp

    <?php
    $path = "./graphics";
    $dir_handle = @opendir($path) or die("Unable to open $path");
    while (false !== ($file = readdir($dir_handle))) {
    if($file == "index.php")
    continue;
    echo "<a href=\"$file\">$file</a><br />"; }
    closedir($dir_handle);
    ?>


    Many Thanks

  8. #7

    Join Date
    Dec 2008
    Location
    Nottingham
    Posts
    575
    Thank Post
    38
    Thanked 115 Times in 105 Posts
    Rep Power
    46
    I would think the following should do it:

    Code:
    echo "<a href=\"$path/$file\">$file</a><br />"; }
    The readdir will dump out to names within that directory, but won't put the path in.

SHARE:
+ Post New Thread

Similar Threads

  1. Lexia Reading
    By bossman in forum Educational Software
    Replies: 20
    Last Post: 27th September 2010, 10:08 AM
  2. Reading festival 2009
    By peterpan in forum Other Stuff
    Replies: 2
    Last Post: 13th March 2009, 11:43 AM
  3. Some Light Reading
    By russdev in forum BSF
    Replies: 6
    Last Post: 15th January 2008, 12:35 AM
  4. Reading FMS from Access
    By LitVer in forum MIS Systems
    Replies: 11
    Last Post: 25th May 2007, 08:19 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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