#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Kouvola, Finland
    Posts
    11
    Rep Power
    0
    hi!

    Any easy way to read the filenames in directory to array and then displaying them hyperlinked [click to view], like this:

    1.[filename]
    2.[filename]
    .
    .

    I appreciate any help, thanks.


    ------------------
    -Aarno Villa
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Location
    London
    Posts
    110
    Rep Power
    0
    this'll do it

    <?
    exec("ls -1 /full path to your folder/*.<whatever file extension>",$lsstr);
    $count=0;
    while($lsstr[$count])
    {
    $file=explode("/",$lsstr[$count]);
    $file=$file[(sizeof($file)-1)];
    echo "<a href="".$file."" target="new"><font color="#000099" face="arial, helvetica" size="1">".$file."</a></font><br>";
    $count++;
    }
    ?>

    hope that helps

    ------------------
    cheers
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 1999
    Location
    UK
    Posts
    50
    Rep Power
    15
    An alternative way of doing it..

    $cas_dir = dir($absolute);
    while($entry=$cas_dir->read()) {
    if ($entry != "." && $entry != "..") {
    echo '<a href="'.$link.$entry.'"target="_blank">'.$entry.'</a><br>';
    }
    }
    $cas_dir->close();

    Where absolute is the full path of the directory and link is the hyperlink path from the file location.

    If you want the Array as well just assign entry to a variable at a counter position.

    Hope this helps as well.

    Falcon
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Kouvola, Finland
    Posts
    11
    Rep Power
    0
    Thanks! it helped much and now I got my script working after all.




    ------------------
    -Aarno Villa

Similar Threads

  1. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 08:27 AM
  2. Sorting file listing by extension?
    By Cyanide in forum PHP Development
    Replies: 2
    Last Post: February 10th, 2004, 12:24 PM
  3. .raw file into 2d array
    By rorybreen1 in forum C Programming
    Replies: 2
    Last Post: January 30th, 2004, 11:02 AM
  4. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 10:47 AM
  5. creating an array and writing it to a csv file
    By bounty5 in forum Visual Basic Programming
    Replies: 7
    Last Post: January 19th, 2004, 07:42 PM

IMN logo majestic logo threadwatch logo seochat tools logo