ftp_exec()
(PHP 4 >= 4.0.3, PHP 5, PHP 7)
请求运行一条 FTP 命令
说明
ftp_exec(resource $ftp_stream,string $command): bool
发送一个 SITE EXEC$command请求到 FTP 服务器。如果成功(服务器发送响应代码200)则返回TRUE
,否则返回FALSE
。
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()。
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.