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

    Join Date
    Sep 2002
    Location
    San Diego
    Posts
    29
    Rep Power
    0

    ftp - displaying file listings


    Hey everyone. Im working on my own personal ftp application. Im in the process of learning how to display the files of a directory.

    PHP Code:
    $conn_id = @ftp_connect($ftp_server$ftp_port);
    $login_result = @ftp_login($conn_id$ftp_user_name$ftp_user_pass);

    foreach(
    ftp_nlist($conn_id$dir) as $entry) {
        if (@
    ftp_chdir($conn_id$entry)) { 
            
    ftp_cdup($conn_id); 
            echo 
    "<a href=\"control.php?action=view&dir=$entry\">".$entry ."</a><br>";
        } else { 
            echo 
    $entry."<br>";
        }

    Here, what im doing is looping through all the links in the dir to see whether they are files or dirs. ftp_chdir tries to open the link and if it is sucessful it will go back to the parent dir and echo a link to that dir. It it is false it will just echo the file name.

    This doesnt work. It seems to only work for the first result then goes dead the rest of the time? Anyone see why?

    Secondly would there be a way to gain more information about the link? To say see how big it was, the type of link it was, etc..

    Thanks
  2. #2
  3. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,898
    Rep Power
    3887
    Hmmm. . . you seem to have posted this in the wrong place. That belongs in the PHP forum.
    ~ishnid
  4. #3
  5. No Profile Picture
    Player
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    San Diego
    Posts
    29
    Rep Power
    0
    Crap. Thanks. Ill move it.

IMN logo majestic logo threadwatch logo seochat tools logo