Actions

API16

JFTP/create

From Joomla! Documentation

< API16:JFTP
Revision as of 16:39, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Method to create an empty file on the FTP server

[Edit Descripton]

Description:JFTP/create

Syntax

create($path)
Parameter Name Default Value Description
$path $path Path local file to store on the FTP server

Returns

boolean True if successful

Defined in

libraries/joomla/client/ftp.php

Importing

jimport( 'joomla.client.ftp' );

Source Body

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;
}

[Edit See Also] SeeAlso:JFTP/create

Examples

<CodeExamplesForm />