A word of caution, execution via FTP isn't very widely supported. Check that it works on the servers that you intend to connect to before you start coding something that requires this.(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)
ftp_exec — Richiede l'esecuzione di un comando sul server FTP
Invia una richiesta SITE EXEC command al server
FTP.
Restituisce true se il comando è stato eseguito correttamente (il server ha inviato il codice di risposta
200); altrimenti restituisce false.
| Versione | Descrizione |
|---|---|
| 8.1.0 |
Il parametro ftp ora si aspetta un'istanza di FTP\Connection;
in precedenza, era attesa una resource.
|
Example #1 Esempio di ftp_exec()
<?php
// inizializzazione delle variabili
$command = 'ls -al >files.txt';
// stabilisce la connessione
$ftp = ftp_connect($ftp_server);
// si collega con nome utente e password
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
// esegue il comando
if (ftp_exec($ftp, $command)) {
echo "$command eseguito correttamente\n";
} else {
echo "impossibile eseguire $command\n";
}
// chiude la connessione
ftp_close($ftp);
?>A word of caution, execution via FTP isn't very widely supported. Check that it works on the servers that you intend to connect to before you start coding something that requires this.