/**
* Method to create an empty file on the FTP server
*
* @param string $path Path local file to store on the FTP server
*
* @return boolean True if successful
*
* @since 1.5
*/
public function create($path)
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE) {
// Turn passive mode on
if (@ftp_pasv($this->_conn, true) === false) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_PASSIVE', __METHOD__), Log::WARNING, 'jerror');
return false;
}
$buffer = fopen('buffer://tmp', 'r');
if (@ftp_fput($this->_conn, $path, $buffer, FTP_ASCII) === false) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_BAD_RESPONSE', __METHOD__), Log::WARNING, 'jerror');
fclose($buffer);
return false;
}
fclose($buffer);
return true;
}
// Start passive mode
if (!$this->_passive()) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_PASSIVE', __METHOD__), Log::WARNING, 'jerror');
return false;
}
if (!$this->_putCmd('STOR ' . $path, array(150, 125))) {
@fclose($this->_dataconn);
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_NOT_EXPECTED_RESPONSE_150_125', __METHOD__, $this->_response, $path), Log::WARNING, 'jerror');
return false;
}
// To create a zero byte upload close the data port connection
fclose($this->_dataconn);
if (!$this->_verifyResponse(226)) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_TRANSFER_FAILED', __METHOD__, $this->_response, $path), Log::WARNING, 'jerror');
return false;
}
return true;
}