Back to FtpClient class

Method chdir

public bool
chdir
(mixed $path)
Method to change the current working directory on the FTP server
Parameters
  • string $path Path to change into on the server
Returns
  • bool True if successful
Since
  • 1.5
Class: FtpClient
Project: Joomla

Method chdir - Source code

/**
 * Method to change the current working directory on the FTP server
 *
 * @param   string  $path  Path to change into on the server
 *
 * @return  boolean True if successful
 *
 * @since   1.5
 */
public function chdir($path)
{
    // If native FTP support is enabled lets use it...
    if (FTP_NATIVE) {
        if (@ftp_chdir($this->_conn, $path) === false) {
            Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_BAD_RESPONSE', __METHOD__), Log::WARNING, 'jerror');
            return false;
        }
        return true;
    }
    // Send change directory command and verify success
    if (!$this->_putCmd('CWD ' . $path, 250)) {
        Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_NOT_EXPECTED_RESPONSE_PATH_SENT', __METHOD__, $this->_response, 250, $path), Log::WARNING, 'jerror');
        return false;
    }
    return true;
}