PHPのftp_chdir()関数
定義と使用法
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リファレンスを完了