X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP ftp_connect() Function

PHP FTP Reference PHP FTP Reference

Example

Connect, login, and close an FTP connection:

<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

// then do something...

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

Definition and Usage

The ftp_connect() function opens an FTP connection to the specified host.

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


Syntax

ftp_connect(host,port,timeout);

Parameter Description
host Required. Specifies the FTP server to connect to. 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 of the FTP server. Default is port 21
timeout Optional. Specifies the timeout for all subsequent network operations. Default is 90 seconds

Technical Details

Return Value: Returns an FTP stream on success or FALSE on error
PHP Version: 4+
PHP Changelog: The timeout parameter was added in PHP 4.2.0


PHP FTP Reference PHP FTP Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook