From Joomla! Documentation

The "API16" 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.

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

Defined in



Method name Description
__construct JFTP object constructor
__destruct JFTP object destructor
getInstance Returns the global FTP connector object, only creating it if it doesn't already exist.
setOptions Set client options
connect Method to connect to a FTP server
isConnected Method to determine if the object is connected to an FTP server
login Method to login to a server once connected
quit Method to quit and close the connection
pwd Method to retrieve the current working directory on the FTP server
syst Method to system string from the FTP server
chdir Method to change the current working directory on the FTP server
reinit Method to reinitialise the server, ie. need to login again
rename Method to rename a file/folder on the FTP server
chmod Method to change mode for a path on the FTP server
delete Method to delete a path [file/folder] on the FTP server
mkdir Method to create a directory on the FTP server
restart Method to restart data transfer at a given byte
create Method to create an empty file on the FTP server
read Method to read a file from the FTP server's contents into a buffer
get Method to get a file from the FTP server and save it to a local file
store Method to store a file to the FTP server
write Method to write a string to the FTP server
listNames Method to list the filenames of the contents of a directory on the FTP server
listDetails Method to list the contents of a directory on the FTP server


jimport( 'joomla.client.ftp' );


Code Examples


$host = 'joomla.org';
$port = 21;
$options = null;
$user = 'randomUserName';
$pass = 'thisIsDefinatlyNotThePassword';


 * 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);

   //We are connected.
   //Let's print the details of the root directory
   echo '<pre>';
   echo '</pre>';

   /* Assuming we only have one "Joomla" directory, this would look like this.
    [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

   //Let's create a file in that new directory

   //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 =)

This example was originally contributed by User:Batch1211.

Chris Davenport 12:07, 17 April 2011 (CDT) Edit comment