Latest web development tutorials
 

PHP ftp_ssl_connect() Function

< PHP FTP Reference

Example

Open a secure SSL-FTP connection:

<?php
// set up basic SSL connection
$ftp_server = "123.123.123.123";
$ftp_conn = ftp_ssl_connect($ftp_server) or die("Could not connect to $ftp_server");

// login
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

// then do something...

// close SSL connection
ftp_close($ftp_conn);
?>

Definition and Usage

The ftp_ssl_connect() function opens a secure SSL-FTP connection.

When the connection is open, you can run FTP functions against the server.

Note: This function is only available if both the ftp module and the OpenSSL support is built statically into PHP.

Syntax

ftp_ssl_connect(host,port,timeout);

Parameter Description
host Required. Specifies the FTP server address. Can be a domain address or an IP address. This parameter should not be prefixed with "ftp://" or have any trailing slashes
port Optional. Specifies the port to connect to. Default is 21
timeout Optional. Specifies the timeout for network operations. Default is 90 seconds

Technical Details

Return Value: Returns a SSL-FTP stream on success or FALSE on error
PHP Version: 4.3+
PHP Changelog: In PHP 5.2.2 this function returns FALSE if it cannot use an SSL connection, instead of fallbacking to a non-SSL connection

< PHP FTP Reference