PHP ftp_exec() 函數
定義和用法
ftp_exec() 函數請求在FTP 服務器上執行一個程序或命令。
如果成功,該函數返回TRUE。 如果失敗,則返回FALSE。
語法
ftp_exec(ftp_connection,command)
参数 | 描述 |
---|---|
ftp_connection | 必需。规定要使用的 FTP 连接。 |
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);
?>
$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);
?>
完整的PHP FTP參考手冊