Joomla! Programmierung/Framework/JFTP

Aus Joomla! Dokumentation
Wechseln zu: Navigation, Suche

Inhaltsverzeichnis

[Bearbeiten] Beschreibung

JFTP ToDo translate is an FTP client class, that allows you to connect and interact with an FTP server.

Der DocComment dient nur zur Referenz - bitte LÖSCHEN
/**
 * FTP client class
 *
 * @package		Joomla.Framework
 * @subpackage	Client
 * @since		1.5
 */

[Bearbeiten] Definiert in

Folder blue.png /libraries/joomla

  • Folder red.png client
    • File php.png ftp.php

[Bearbeiten] Status

  • @since Joomla 1.5

[Bearbeiten] Importieren

jimport( 'joomla.client.ftp' );

[Bearbeiten] Erweitert

JObject

[Bearbeiten] Wird erweitert von

  • Keine

[Bearbeiten] Methoden

Name Beschreibung
__construct Constructor. Set's transfer type and other options.
__destruct Destructor. Makes sure the FTP server connection is closed at the end of script.
getInstance Returns a reference to the global FTP connector object, only creating it, if it doesn't already exist.
setOptions Sets options of this FTP client object
connect Connects the object to a FTP server.
isConnected Determines if the object is connected to an FTP server
login Login to a server once connected
quit Quits and closes the connection
pwd Retrieves the current working directory on the FTP server
syst Gets the system identifier string from the FTP server
chdir Changes the current working directory on the FTP server.
reinit Reinitializes the server, i.e. logs in again.
rename Renames a file/folder on the FTP server
chmod Changes the mode for a path on the FTP server.
delete Deletes a path(file/folder) on the FTP server.
mkdir Creates a directory on the FTP server
restart Restarts data transfer at a given byte.
create Creates an empty file on the FTP server.
read Reads a file from the FTP server's contents into a buffer
get Gets a file from the FTP server and saves it to a given local file.
store Stores a file to the FTP server
write Writes a string to a certain file on the FTP server.
listNames Lists the filenames of the contents of a directory on the FTP server
listDetails Lists the contents of a directory on the FTP server

[Bearbeiten] Beispiele

$host = 'joomla.org';
$port = 21;
$options = null;
$user = 'randomUserName';
$pass = 'thisIsDefinatlyNotThePassword';
 
jimport('joomla.client.ftp');
 
/*
 * The JFTP::getInstance() method will connect us to the FTP server and automatically
 * log us in. We could do the same with the connect() and login() methods. Also check 
 * out JClientHelper::getCredentials('ftp');
 */
 
$ftp = JFTP::getInstance($host, $port, $options, $user, $pass);
 
if($ftp->isConnected())
{
   /* We are connected. */
 
   /* Let's print the details of the root directory */
   echo '<pre>';
   print_r($ftp->listDetails());
   echo '</pre>';
 
   /* Assuming we only have one "Joomla" directory, this would look like this.
   Array
   (
    [0] => Array
        (
            [type] => 1
            [rights] => drwxr-xr-x
            [user] => randomUserName
            [group] => ftpusers
            [size] => 4096
            [date] => 03-15
            [time] => 2008
            [name] => Joomla
        )
   )
   */
 
   /* Let's create a directory */
   $ftp->mkdir('test');
 
   /* Let's create a file in that new directory */
   $ftp->create('test/fairyTale.txt');
 
   /* Let's write the first line of our Fairy Tale into our newly created text file */
   $ftp->write('test/fairyTale.txt', 'Once upon a time, there was a litte Mermaid, called Arielle');
 
   /* Let's read the fairy tale out of the file, and echo it out. */
   $fairyTale = '';
   $ftp->read('test/fairyTale.txt', $fairyTale);
   echo $fairyTale;
 
   /* Let's think of a name for our fairyTale, and rename the file */
   $ftp->rename('test/fairyTale.txt', 'test/Arielle.txt');
 
/**
 * I think you got the idea =)
 */
}

[Bearbeiten] Siehe auch

  • JFTP auf api.joomla.org
Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
Sonstiges
Team Navigation
Werkzeuge