PHP | ftp_ssl_connect() Function Last Updated : 07 Aug, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The ftp_ssl_connect() function is an inbuilt function in PHP which opens a secure SSL-FTP connection. FTP functions can be run against the server while the connection is open. It opens an explicit SSL-FTP connection to the host specified in parameter. It will succeed even if the server's certificate is invalid or is not configured for SSL-FTP. Syntax: ftp_ssl_connect($host, $port, $timeout); Parameters: This function accepts three parameters as mentioned above and described below: $host: It is required parameter. It specifies the FTP server address. It can be a domain address or an IP address. This parameter shouldn't be prefixed with "ftp://" or shouldn't have any trailing slashes.$port: It is an optional parameter. It specifies the port to connect to. If no port is provided then default port is used i.e. 21.$timeout: It is also an optional parameter. It specifies the timeout for network operations. If not provided then default value is passed which is 90 seconds. Return Value: It returns SSL-FTP stream on success or false on failure. Note: This function is available on PHP 4.0.0 and newer version.The following examples cannot be run on online IDE. So try to run in some PHP hosting server or localhost with proper ftp server name.This function is only available if both the ftp module and the OpenSSL support is built statically into PHP. Below programs illustrate the ftp_ssl_connect() function in PHP: Example 1: PHP <?php // Use ftp_ssl_connect() function to // check Connection $conn = ftp_ssl_connect("ftp.testftp.com") or die("Could not connect"); echo "Connection established successfully"; ?> Output: Connection established successfully Example 2: This example uses ftp_ssl_connect() function to logging in using SSL-FTP Connection PHP <?php // Setting up basic SSL connection // User IP address to which you // want to connect to $ftp_server = "8.8.8.8"; // Logging in in the established ftp connection. $ftp_conn = ftp_ssl_connect($ftp_server) or die("Could not connect to $ftp_server"); // Use your username $ftp_username = "your_username"; // Use your password $ftp_userpass = "your_password"; $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass); if( $login ) { echo "Successfully logged in with ".$ftp_server; } else { echo "Log in failed"; } // Closing SSL connection ftp_close($ftp_conn); ?> Output: Successfully logged in with 8.8.8.8 References: https://www.php.net/manual/en/function.ftp-ssl-connect.php Comment More infoAdvertise with us Next Article PHP | ftp_alloc() function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- FTP Similar Reads PHP | ftp_connect() function The ftp_connect() function is an inbuilt function in PHP which is used to create a new connection to the specified FTP server or Host. When connection is successful then only other FTP functions can be run against the server. Syntax:Â ftp_connect( $ftp_host, $ftp_port, $timeout ); Parameter: This fu 2 min read PHP | connection_status() Function The connection_status() function is an inbuilt function in PHP which returns the current connection status. Syntax: int connection_status( void ) Parameters: This function doesn't accept any parameters. Return Value: This function returns the connection status bitfield. The possible values of return 2 min read PHP | ftp_exec() function The ftp_exec() function is an inbuilt function in PHP that is used to execute a command on the FTP server. Syntax:Â ftp_exec( $ftp_connection, $command ) Parameters: This function accepts two parameters as mentioned above and described below:Â Â $ftp_connection: It is required parameter. It specifies 2 min read PHP | ftp_alloc() function The ftp_alloc() function is an inbuilt function in PHP which is used to allocate space for file to be uploaded in FTP server.Syntax:Â Â ftp_alloc( $ftp_connection, $filesize, $result ); Parameter: This function accepts three parameters as mentioned above and described below:Â Â $ftp_connection: It is 3 min read PHP | ftp_delete() function The ftp_delete() function is an inbuilt function in PHP which is used to delete a file on the FTP server. Syntax:Â ftp_delete( $ftp_connection, $file ) Parameters: This function accepts two parameters as mentioned above and described below:Â Â $ftp_connection: It is required parameter. It specifies t 2 min read PHP | ftp_size() function The ftp_size() function is an inbuilt function in PHP which is used to get the size of a given file on FTP server.Syntax:Â Â ftp_size( $ftp_connection, $file_name ); Parameter: This function accepts two parameters as mentioned above and described below:Â Â $ftp_connection: It is required parameter. It 3 min read Like