A question about PHP

Discussion in 'PHP' started by Crayz, Nov 7, 2006.

  1. #1
    Hello, is it possible to pull all of the files out of a directory with a php script, and use their names, urls, or w/e else and list them on the page, without the files information stored somewhere like a mysql database?

    Thanks
     
    Crayz, Nov 7, 2006 IP
  2. edD

    edD Peon

    Messages:
    146
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think you're asking how to list the files in the directory, right?

    IF so, there are examples in the manual of how to do this.

    http://us3.php.net/manual/en/function.readdir.php
     
    edD, Nov 7, 2006 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Untested, but give it a try.

    
    
    <?php
    
    $dir = './path/to/files/*';
    
    foreach (glob($dir) AS $file)
    {
         echo '<p style="margin:2px">'. $file .'</p>'. "\n";
    }
    
    ?>
    
    
    PHP:
     
    nico_swd, Nov 8, 2006 IP
  4. Crayz

    Crayz Well-Known Member

    Messages:
    708
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    120
    #4
    Ok cool, thanks guys!
     
    Crayz, Nov 8, 2006 IP