Page 1 of 1

FTP list folders

Posted: Sun Sep 16, 2007 1:15 pm
by user___
Hi guys,
I have been trying to display all folders on a remote FTP server but I could not find a solution. I tried the raw list function but the problem comes from the fact that it reads only files and as soon as I created a folder my script got stuck. Do you have any ideas of how to do that because I could not find an exact function for that task.

Posted: Sun Sep 16, 2007 1:58 pm
by feyd
Post your code.

Reply

Posted: Sun Sep 16, 2007 2:12 pm
by user___
Thank you for the fast reply, feyd. The test code I have (Actually I have a class which has a function whose fubctionality is sinilkar to that sample) is a sample from http://www.php.net. It is used to print files and folders on the remote host but when there is a direcory it gets stuck.
This is the code:

Code: Select all

<?php

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// get the file list for /
$buff = ftp_rawlist($conn_id, '/');

// close the connection
ftp_close($conn_id);

// output the buffer
var_dump($buff);
?>

Posted: Sun Sep 16, 2007 3:12 pm
by s.dot
ftp_nlist() example in the manual page shows the function returning folder names.