API16

API16:JFTP/pwd

From Joomla! Documentation

Revision as of 01:38, 25 March 2017 by JoomlaWikiBot (talk | contribs) (preparing for archive only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Method to retrieve the current working directory on the FTP server


<! removed transcluded page call, red link never existed >

Syntax

pwd()


Returns

string Current working directory

Defined in

libraries/joomla/client/ftp.php

Importing

jimport( 'joomla.client.ftp' );

Source Body

function pwd() {

        // If native FTP support is enabled lets use it...
        if (FTP_NATIVE) {
                if (($ret = @ftp_pwd($this->_conn)) === false) {
                        JError::raiseWarning('35', 'JFTP::pwd: Bad response');
                        return false;
                }
                return $ret;
        }

        // Initialise variables.
        $match = array (null);

        // Send print working directory command and verify success
        if (!$this->_putCmd('PWD', 257)) {
                JError::raiseWarning('35', 'JFTP::pwd: Bad response', 'Server response: '.$this->_response.' [Expected: 257]');
                return false;
        }

        // Match just the path
        preg_match('/"[^"\r\n]*"/', $this->_response, $match);

        // Return the cleaned path
        return preg_replace("/\"/", "", $match[0]);
}


<! removed transcluded page call, red link never existed >

Examples

Code Examples