'host', 'username' => 'user', 'password' => 'pass', 'debug' => true, ); // Connect to FTP $ftp = new CI_FTP($config); if ($ftp->connect() === false) { throw new Exception("PHP was not able to connect to {$this->getFtpHost()}"); } // Loop trough files and transfer them to FTP $files = array( 'test.txt' => 'test/test.txt', ); foreach($files as $localFilename => $remoteFilename) { // Create dir if doesn't exsists if ($ftp->is_dir($remoteFilename) === false) { $ftp->mkdir_recursive(dirname($remoteFilename), 0777); } // Save file to FTP $ftp->upload($localFilename, $remoteFilename); echo $remoteFilename . " uploaded\n"; } ?>