Current Location: Home> Function Categories> ftp_connect

ftp_connect

Open the FTP connection.
Name:ftp_connect
Category:Uncategorized
Programming Language:php
One-line Description:Open the FTP connection.

Definition and usage

ftp_connect() function establishes a new FTP connection.

If successful, a connection identifier is returned, otherwise false is returned.

Example

This example attempts to connect to an FTP server. If the connection fails, the die() function terminates the script and outputs a message:

 <?php
$conn = ftp_connect ( "ftp.testftp.com" ) or die ( "Could not connect" ) ;
?>

grammar

 ftp_connect ( host , port , timeout )
parameter describe
host

Required. Specifies the FTP server to connect to. Can be a domain name or an IP address.

The back should not end with a slash, and the front should not start with ftp://.

port Optional. Specifies the port of the FTP server.
timeout Optional. Specifies the timeout time of the FTP server. The default is 90 seconds.

illustrate

Tip: The timeout time can be changed and obtained at any time through the functions ftp_set_option() and ftp_get_option() .

The parameter timeout is only available for PHP 4.2.0 and above.

Similar Functions
Popular Articles