phpday 2027 - Call for Papers

ftp_exec

(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)

ftp_exec — Richiede l'esecuzione di un comando sul server FTP

Descrizione

function ftp_exec(FTP\Connection $ftp, string $command): bool

Invia una richiesta SITE EXEC command al server FTP.

Elenco dei parametri

ftp

Un'istanza di FTP\Connection.

command

Il comando da eseguire.

Valori restituiti

Restituisce true se il comando è stato eseguito correttamente (il server ha inviato il codice di risposta 200); altrimenti restituisce false.

Log delle modifiche

Versione Descrizione
8.1.0 Il parametro ftp ora si aspetta un'istanza di FTP\Connection; in precedenza, era attesa una resource.

Esempi

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);

?>

Vedere anche:

  • ftp_raw() - Invia un comando arbitrario a un server FTP

+add a note

User Contributed Notes 1 note

up
0
sam at totallydigital dot co dot nz
22 years ago
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.
To Top