php folder files retrieve

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jacotheron
    New Member
    • Jan 2008
    • 44

    php folder files retrieve

    Hi all
    I need a php script that can access a folder on the server to list all the files in the folder. While trying to get a solution, I found this script that can list folders in the wamp index.php-file:
    [code=php]<?php
    $projectsListIg nore = array ('.','..');
    $handle=opendir (".");
    $projectContent s = '';
    while ($file = readdir($handle ))
    {
    if (is_dir($file) && !in_array($file ,$projectsListI gnore))
    {
    $projectContent s .= '<li><a href="'.$file.' ">'.$file.' </a></li>';
    }
    }
    closedir($handl e);
    if (!isset($projec tContents))
    $projectContent s = $langues[$langue]['txtNoProjet'];
    ?>[/code]

    it should also link towards the files that get listed

    Can someone please help me

    Merry Christmas to all
    Last edited by pbmods; Dec 30 '08, 12:17 AM. Reason: Fixed CODE tags.
  • djpaul
    New Member
    • Oct 2006
    • 137

    #2
    Hey Jacotheron.
    Sure it's possible!
    [code=php]
    <?php
    $handle=opendir (".");

    while ($file = readdir($handle )) {

    if ((is_dir($file) && (substr ($file, 0, 1) != '.' )){

    $projectContent s = '<li><a href="' . $file . '">' . $file . '</a></li>';

    }//end if

    }//end while

    closedir($handl e);

    if (!isset($projec tContents))
    $projectContent s = $langues[$langue]['txtNoProjet'];
    ?>
    [/code]

    Maybe this will work, try it or download the php manual.
    There are many tutorials in it!

    greetz paul
    Last edited by Atli; Dec 30 '08, 02:23 PM. Reason: Replaced the [quote] tags with [code] tags.

    Comment

    Working...