API15

JFTP/create

From Joomla! Documentation

< API15:JFTP
Revision as of 12:20, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)

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 create an empty file on the FTP server

[<! removed edit link to red link >]

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

Syntax[edit]

create($path)
Parameter Name Default Value Description
$path $path Path local file to store 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 create($path) {

        // 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::create: Unable to use passive mode' );
                        return false;
                }

                $buffer = fopen('buffer://tmp', 'r');
                if (@ftp_fput($this->_conn, $path, $buffer, FTP_ASCII) === false) {
                        JError::raiseWarning('35', 'JFTP::create: Bad response' );
                        fclose($buffer);
                        return false;
                }
                fclose($buffer);
                return true;
        }

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

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

        // To create a zero byte upload close the data port connection
        fclose($this->_dataconn);

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

        return true;
}

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

Examples[edit]

<CodeExamplesForm />