FTP 函数
在线手册:中文  英文

ftp_exec

(PHP 4 >= 4.0.3, PHP 5)

ftp_exec请求运行一条 FTP 命令

说明

bool ftp_exec ( resource $ftp_stream , string $command )

发送一个 SITE EXEC command 请求到 FTP 服务器。如果成功(服务器发送响应代码 200)则返回 TRUE,否则返回 FALSE

Example #1 ftp_exec() 例子

<?php
$command 
'ls -al';
$conn_id ftp_connect($ftp_server);
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);
if(
$res ftp_exec($conn_id$command)) {
    echo 
"$command executed successfully<br />\n";
    echo 
nl2br($res);
} else {
    echo 
'could not execute ' $command;
}
?>

参见 ftp_raw()


FTP 函数
在线手册:中文  英文

用户评论:

chris dot pittman at sonopress dot com (2005-09-15 06:34:24)

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 (2003-12-16 01:34:05)

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.

易百教程