PHP ftp_mlsd()関数
例
「images」ディレクトリからファイルのリストを返します。
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$dir = "/images";
$dirlist = ftp_mlsd($ftp_conn, $dir);
// output directory list
echo($dirlist);
// close connection
ftp_close($ftp_conn);
?>
定義と使用法
ftp_mlsd()関数は、指定されたディレクトリ内のファイルのリストを返します。
構文
ftp_mlsd(ftp_conn, dir);
パラメータ値
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to use |
dir | Required. Specifies the name of the directory to be listed. Use "." to get the current directory |
技術的な詳細
戻り値: | 成功した場合は指定されたディレクトリからのファイル情報を含む配列、失敗した場合はFALSE |
---|---|
PHPバージョン: | 7.2+ |
❮PHPFTPリファレンス