The below example doesn't seem to work on a windows based machine so I use this trick instead
<?php
$aPath = explode('/',ftp_pwd($conn_id));
$sHomeDir = str_repeat('../', count($aPath) - 1);
ftp_chdir($conn_id, $sHomeDir);
?>
(PHP 4, PHP 5, PHP 7, PHP 8)
ftp_cdup — 親ディレクトリに移動する
バージョン | 説明 |
---|---|
8.1.0 |
引数 ftp は、FTP\Connection
のインスタンスを期待するようになりました。
これより前のバージョンでは、resource を期待していました。
|
例1 ftp_cdup() の例
<?php
/ 接続を確立する
$ftp = ftp_connect($ftp_server);
/ ユーザー名とパスワードでログインする
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
/ html ディレクトリに移動する
ftp_chdir($ftp, 'html');
echo ftp_pwd($ftp); / /html
/ 親ディレクトリに戻る
if (ftp_cdup($ftp)) {
echo "cdup successful\n";
} else {
echo "cdup not successful\n";
}
echo ftp_pwd($ftp); / /
ftp_close($ftp);
?>
The below example doesn't seem to work on a windows based machine so I use this trick instead
<?php
$aPath = explode('/',ftp_pwd($conn_id));
$sHomeDir = str_repeat('../', count($aPath) - 1);
ftp_chdir($conn_id, $sHomeDir);
?>
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 ;)
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant