ftp_cdup can only up to the parent and if you want test a directory that is not a child then you can't with ftp_cdup ;)
(PHP 4, PHP 5, PHP 7, PHP 8)
ftp_cdup — 親ディレクトリに移動する
$ftp
): bool親ディレクトリに移動します。
ftp
FTP 接続のリンク ID 。
成功した場合に true
を、失敗した場合に false
を返します。
例1 ftp_cdup() の例
<?php
// 接続を確立する
$conn_id = ftp_connect($ftp_server);
// ユーザー名とパスワードでログインする
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// html ディレクトリに移動する
ftp_chdir($conn_id, 'html');
echo ftp_pwd($conn_id); // /html
// 親ディレクトリに戻る
if (ftp_cdup($conn_id)) {
echo "cdup successful\n";
} else {
echo "cdup not successful\n";
}
echo ftp_pwd($conn_id); // /
ftp_close($conn_id);
?>
ftp_cdup can only up to the parent and if you want test a directory that is not a child then you can't with ftp_cdup ;)