CI_FTP::connect()

connect([$config = array()])

Parameters:
  • $config (array) – Connection values
Returns:

TRUE on success, FALSE on failure

Return type:

bool

Connects and logs into to the FTP server. Connection preferences are set by passing an array to the function, or you can store them in a config file.

Here is an example showing how you set preferences manually:

$this->load->library('ftp');

$config['hostname'] = 'ftp.example.com';
$config['username'] = 'your-username';
$config['password'] = 'your-password';
$config['port']     = 21;
$config['passive']  = FALSE;
$config['debug']    = TRUE;

$this->ftp->connect($config);

Setting FTP Preferences in a Config File

If you prefer you can store your FTP preferences in a config file. Simply create a new file called the ftp.php, add the $config array in that file. Then save the file at application/config/ftp.php and it will be used automatically.

Available connection options

Option name Default value Description
hostname n/a FTP hostname (usually something like: ftp.example.com)
username n/a FTP username
password n/a FTP password
port 21 FTP server port number
debug FALSE TRUE/FALSE (boolean): Whether to enable debugging to display error messages
passive TRUE TRUE/FALSE (boolean): Whether to use passive mode
doc_CodeIgniter
2016-10-15 16:31:35
Comments
Leave a Comment

Please login to continue.