Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

PHP - FTP list files

1

47 views

I am new to the FTP feature of PHP. I have a directory within my FTP location called documents. I need to get the folders/files within another directory. So like this basically:

root/documents/Ryan-Hart/ <-all-files/folders-here

So how can I show and link to these from PHP. I have tried this:

$name = "Ryan-Hart";

$conn_id = ftp_connect($ftp_server);

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

print_r(ftp_nlist($conn_id,"/documents/$name"));

But that comes out in array. How can a echo out the name (plus extension) of file and link to them?

asked March 5, 2011 11:24 am CST
posted via StackOverflow

1 Answer

2
Best answer
 

Are you looking for something like that?

$arr= ftp_nlist($conn_id,"/documents/$name");

foreach ($arr as $value)
{
  $temp = split($value);
  echo '<a href="'.$value.'">'.$temp[count($temp)-1]'</a>';
}

answered March 5, 2011 12:23 pm CST

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
DNS - List all entries
February 19, 2011
PHP - Query from a list
February 19, 2011
Tag cloud/weighted list
February 18, 2011