• Welcome to Simple Machines Community Forum. Please login or sign up.



Retrieves a directory listing for the specified directory.


string ftp_connection::list_dir ([string $ftp_path[, bool $search]])

Parameter $ftp_path

Expected type: String
Description: The path to a directory (other than the current one) to get the listing for

Parameter $search

Expected type: Boolean
Description: If true, will do a recursive listing showing the contents of any subdirectories as well. Default is false.

Return value

Expected type: String
Description: The directory listing returned by FTP, or false if the listing could not be retrieved


  • Example: $package_ftp->list_dir('/public_html');
  • Sends the "LIST -1" command to the server ("1" means list 1 file per line)
  • Appends "R" flag to the above command if $search is true ("R" = recursive)
  • Checks for either a 150 or 226 response code
  • Sets a 'bad_response' error, attempts to close the passive connection and returns false if the response code isn't 150 or 226