PHP ftp_exec()Fonction
Manuel de référence complet PHP FTP
Définition et utilisation
La fonction ftp_exec() demande l'exécution d'un programme ou d'une commande sur le serveur FTP.
Retourne TRUE en cas de succès, ou FALSE en cas d'échec.
Syntaxe
ftp_exec(ftp_connection,command)
| Parameters | Description |
|---|---|
| ftp_connection | Obligatoire. Spécifie la connexion FTP à utiliser. |
| command | Obligatoire. Spécifie la requête de commande à envoyer au serveur FTP. |
Conseils et notes
Note :Contrairement à la fonction ftp_raw(), ftp_exec() ne peut envoyer des commandes qu'après s'être connecté au serveur FTP.
Exemples
<?php
$command = "ls-al > test.txt";
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
if (ftp_exec($conn,$command))
{
echo "Command executed successfully";
}
else
{
echo "Execution of command failed";
}
ftp_close($conn);
?>
$command = "ls-al > test.txt";
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
if (ftp_exec($conn,$command))
{
echo "Command executed successfully";
}
else
{
echo "Execution of command failed";
}
ftp_close($conn);
?>
Manuel de référence complet PHP FTP Autres extensions