
March 10th, 2003, 02:57 AM
|
|
Player
|
|
Join Date: Sep 2002
Location: San Diego
Posts: 28
Time spent in forums: 1 m 15 sec
Reputation 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
|