API15

Difference between revisions of "JFTP/get"

From Joomla! Documentation

< API15:JFTP
(New page: ===Description=== Method to get a file from the FTP server and save it to a local file <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JFTP/get|Edit ...)
 
m (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JFTP/get|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JFTP/get}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 97: Line 97:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JFTP/get|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JFTP/get}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 112: Line 112:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Revision as of 12:20, 12 May 2013

The "API15" 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 get a file from the FTP server and save it to a local file

[<! removed edit link to red link >]

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

Syntax[edit]

get($local, $remote)
Parameter Name Default Value Description
$local $local Path to local file to save remote file as
$remote $remote Path to remote file to get on the FTP server

Returns[edit]

boolean True if successful

Defined in[edit]

libraries/joomla/client/ftp.php

Importing[edit]

jimport( 'joomla.client.ftp' );

Source Body[edit]

function get($local, $remote) {

        // Determine file type
        $mode = $this->_findMode($remote);

        // If native FTP support is enabled lets use it...
        if (FTP_NATIVE) {
                // turn passive mode on
                if (@ftp_pasv($this->_conn, true) === false) {
                        JError::raiseWarning('36', 'JFTP::get: Unable to use passive mode' );
                        return false;
                }

                if (@ftp_get($this->_conn, $local, $remote, $mode) === false) {
                        JError::raiseWarning('35', 'JFTP::get: Bad response' );
                        return false;
                }
                return true;
        }

        $this->_mode($mode);

        // Check to see if the local file can be opened for writing
        $fp = fopen($local, "wb");
        if (!$fp) {
                JError::raiseWarning('38', 'JFTP::get: Unable to open local file for writing', 'Local path: '.$local );
                return false;
        }

        // Start passive mode
        if (!$this->_passive()) {
                JError::raiseWarning('36', 'JFTP::get: Unable to use passive mode' );
                return false;
        }

        if (!$this->_putCmd('RETR '.$remote, array (150, 125))) {
                @ fclose($this->_dataconn);
                JError::raiseWarning('35', 'JFTP::get: Bad response', 'Server response: '.$this->_response.' [Expected: 150 or 125] Path sent: '.$remote );
                return false;
        }

        // Read data from data port connection and add to the buffer
        while (!feof($this->_dataconn)) {
                $buffer = fread($this->_dataconn, 4096);
                $ret = fwrite($fp, $buffer, 4096);
        }

        // Close the data port connection and file pointer
        fclose($this->_dataconn);
        fclose($fp);

        if (!$this->_verifyResponse(226)) {
                JError::raiseWarning('37', 'JFTP::get: Transfer Failed', 'Server response: '.$this->_response.' [Expected: 226] Path sent: '.$remote );
                return false;
        }

        return true;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />