PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ftp_fget> <ftp_delete
Last updated: Fri, 05 Sep 2008

view this page in

ftp_exec

(PHP 4 >= 4.0.3, PHP 5)

ftp_execExécute une commande sur un serveur FTP

Description

bool ftp_exec ( resource $ftp_stream , string $command )

ftp_exec() envoie une commande SITE EXEC au serveur FTP, pour qu'il exécute le programme command .

Liste de paramètres

ftp_stream

L'identifiant du lien de connexion FTP.

command

La commande à exécuter.

Valeurs de retour

Retourne TRUE si la commande a été exécutée avec succès (le serveur envoie le code réponse : 200); sinon, retourne FALSE.

Exemples

Exemple #1 Exemple avec ftp_exec()

<?php

// Initialisation de la variable
$command 'ls -al >files.txt';

// Initialisation de la connexion
$conn_id ftp_connect($ftp_server);

// Identification
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// Éxécution d'une commande
if (ftp_exec($conn_id$command)) {
    echo 
"$command a été exécuté avec succès\n";
} else {
    echo 
"Impossible d\'exécuter : $command\n";
}

// Fermeture de la connexion
ftp_close($conn_id);

?>

Voir aussi



add a note add a note User Contributed Notes
ftp_exec
chris dot pittman at sonopress dot com
15-Sep-2005 03:34
I've been using the php ftp functions pretty extensively at work.  We've recently discovered that some of the ftp servers we connect to, paticularly in Europe, are using extended passive mode.  On a server using extended passive mode the php ftp functions will timeout.  For those of you who encounter this, the solution is to send the command:

ftp_exec (conn_id, 'epsv4 off' );

Do this immediately after ftp_login and you should be fine.
sam at totallydigital dot co dot nz
16-Dec-2003 10:34
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.

ftp_fget> <ftp_delete
Last updated: Fri, 05 Sep 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites