PHP ftp_nlist()関数
例
現在のディレクトリ内のファイルを一覧表示します。
<?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);
// get file list of current directory
$file_list = ftp_nlist($ftp_conn, ".");
var_dump($file_list);
// close connection
ftp_close($ftp_conn);
?>
定義と使用法
ftp_nlist()関数は、FTPサーバー上の指定されたディレクトリにあるファイルのリストを返します。
構文
ftp_nlist(ftp_conn, dir);
パラメータ値
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to use |
dir | Required. Specifies the directory to be listed. Use "." to get the current directory |
技術的な詳細
戻り値: | 成功した場合は指定されたディレクトリからのファイル名の配列、失敗した場合はFALSE |
---|---|
PHPバージョン: | 4歳以上 |
❮PHPFTPリファレンス