Funzione PHP ftp_connect()
Esempio
Connetti, accedi e chiudi una connessione FTP:
<?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);
?>
Definizione e utilizzo
La funzione ftp_connect() apre una connessione FTP all'host specificato.
Quando la connessione è aperta, è possibile eseguire le funzioni FTP sul server.
Sintassi
ftp_connect(host, port, timeout);
Valori dei parametri
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 |
Dettagli tecnici
Valore di ritorno: | Un flusso FTP in caso di successo o FALSE in caso di errore |
---|---|
Versione PHP: | 4+ |
Registro delle modifiche PHP: | Il parametro timeout è stato aggiunto in PHP 4.2.0 |
❮ Riferimento FTP PHP