JFTP/create: Difference between revisions
From Joomla! Documentation
m removing red link to edit, no existant pages |
m preparing for archive only |
||
| Line 82: | Line 82: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=create | category=create | ||
category=JFTP | category=JFTP | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
Latest revision as of 00:36, 25 March 2017
Description
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
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;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples