PHP ftp_exec() 函数
定义和用法
ftp_exec() 函数请求在 FTP 服务器上执行一个程序或命令。
若成功(服务器发送响应代码 200),则返回 true,否则返回 false。
语法
ftp_exec(ftp_connection,command)
| 参数 | 描述 | 
|---|---|
| ftp_connection | 必需。规定要使用的 FTP 连接(FTP 连接的标识符)。 | 
| command | 必需。规定发送到服务器的命名请求。 | 
说明
该函数发送一个 SITE EXEC command 请求到 FTP 服务器。
提示和注释
与 ftp_raw() 函数 不同,ftp_exec() 只有在登录到 FTP 服务器后才能发送命令。
例子
<?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);
?>
