PHP ftp_chdir()関数
完全なPHP FTPリファレンスマニュアル
定義と使い方
ftp_chdir() 関数は、FTPサーバー上の現在のディレクトリを指定したディレクトリに変更します。
成功した場合、この関数は TRUE を返します。失敗した場合は、FALSE と警告を返します。
構文
ftp_chdir(ftp_connection,directory)
| パラメータ | 説明 |
|---|---|
| ftp_connection | 必須です。使用するFTP接続を指定します。 |
| directory | 必須です。切り替えるディレクトリを指定します。 |
例
<?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);
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);
ftp_close($ftp_server);
?>
上記のコードは次のように出力します:
Dir: /
Dir: /images
Dir: /images
完全なPHP FTPリファレンスマニュアル その他の拡張機能