From Joomla! Documentation


$host = '';
$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