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



Attempts to locate the specified file or directory.


string ftp_connection::locate (string $file[, string $listing])

Parameter $file

Expected type: String
Description: The name of a file or directory to locate

Parameter $listing

Expected type: String
Description: A directory listing returned by list_dir (if not specified it will search starting in the current directory)

Return value

Expected type: String
Description: The complete path to the specified file, or false if it couldn't be located.


  • Example: $package_ftp->locate('package-info.xml');
  • $listing should be a string returned by list_dir
  • If $listing isn't specified, will do a recursive listing on the current dir before searching
  • Sends the PWD (Print Working Directory) command to the server
  • Checks response of PWD and sets $current_dir to the result of that command if it receives a 257 response code
  • Goes through each file/directory and matches it against $file
  • Returns the path/filename if it's found
  • Returns false otherwise