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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Advanced directory listing?

    Hi there,

    I can do a basic directory listing. But what I would like is to be able to use the result; for example, display all images in a directory, or create links to all files.

    I've tried to do this using str_replace() {as it's one of half a dozen functions I actually know } but I have a problem with three dots messing things up ... So I'm thinking surely there's a better way?

    cheers
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this might be relevant
    PHP Code:
    <?

    //define the path as relative
    $path ".";

    //open directory for list
    $dir_handle = @opendir($path) or die("Unable to open $path");

    //print filenames
    print "<pre>";
    while (
    $file readdir($dir_handle)) {
        
    //if filename contains .shtml or .phtml 
        
    if(ereg("\.[sp]html",$file) {
            
            print 
    "<a href=\"$file\">$file</a>\n";
            }
        }

    //close directory
    closedir($dir_handle);
    print 
    "</pre>";
      
    ?>
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That works, well it doesn't with the [sp] bit in place but there's ways around for multiple file types...
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "insert regex here", innit
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

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