API16

JFTP/rename

From Joomla! Documentation

< API16:JFTP
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Method to rename a file/folder on the FTP server


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

Syntax[edit]

rename($from, $to)
Parameter Name Default Value Description
$from $from Path to change file/folder from
$to $to Path to change file/folder to

Returns[edit]

boolean True if successful

Defined in[edit]

libraries/joomla/client/ftp.php

Importing[edit]

jimport( 'joomla.client.ftp' );

Source Body[edit]

function rename($from, $to) {

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

        // Send rename from command to the server
        if (!$this->_putCmd('RNFR '.$from, 350)) {
                JError::raiseWarning('35', 'JFTP::rename: Bad response', 'Server response: '.$this->_response.' [Expected: 320] From path sent: '.$from);
                return false;
        }

        // Send rename to command to the server
        if (!$this->_putCmd('RNTO '.$to, 250)) {
                JError::raiseWarning('35', 'JFTP::rename: Bad response', 'Server response: '.$this->_response.' [Expected: 250] To path sent: '.$to);
                return false;
        }

        return true;
}


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

Examples[edit]

Code Examples[edit]