PHP ftp_cdup() 函數
定義和用法
ftp_cdup() 函數把當前目錄改變為FTP 服務器上的父目錄。
如果成功,該函數返回TRUE。 如果失敗,則返回FALSE。
語法
ftp_cdup(ftp_connection)
参数 | 描述 |
---|---|
ftp_connection | 必需。规定要使用的 FTP 连接。 |
實例
<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
//Outputs the current directory
echo "Dir: ".ftp_pwd($conn);
echo "<br />";
//Change to the images directory
ftp_chdir($conn,"images");
echo "Dir: ".ftp_pwd($conn);
echo "<br />";
//Change current directory to parent directory
ftp_cdup($conn);
echo "Dir: ".ftp_pwd($conn);
ftp_close($ftp_server);
?>
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
//Outputs the current directory
echo "Dir: ".ftp_pwd($conn);
echo "<br />";
//Change to the images directory
ftp_chdir($conn,"images");
echo "Dir: ".ftp_pwd($conn);
echo "<br />";
//Change current directory to parent directory
ftp_cdup($conn);
echo "Dir: ".ftp_pwd($conn);
ftp_close($ftp_server);
?>
上面的代碼將輸出:
Dir: /
Dir: /images
Dir: /
Dir: /images
Dir: /
完整的PHP FTP參考手冊