返回指定目錄下檔案的詳細列表

ftp_rawlist

(PHP 4, PHP 5, PHP 7, PHP 8)

ftp_rawlist返回指定目錄下檔案的詳細列表

說明

ftp_rawlist(resource $ftp_stream, string $directory, bool $recursive = false): array

ftp_rawlist() 函式將執行 FTP LIST 命令,並把結果做為一個陣列返回。

參數

ftp_stream

FTP 連線資源。

directory

要操作的目錄路徑,可以包括 LIST 參數。

recursive

如果此參數為 true,實際執行的命令將會為 LIST -R

返回值

返回一個陣列,陣列的每個元素為返回文字的每一行,輸出結構不會被解析。使用函式 ftp_systype() 可以用來判斷 FTP 伺服器的型別,從而可以用來判斷返回列表的型別。

The output is not parsed in any way. The system type identifier returned by ftp_systype() can be used to determine how the results should be interpreted.

範例

示例 #1 ftp_rawlist() 示例

<?php

// 初始化連線
$conn_id ftp_connect($ftp_server);

// 使用使用者名稱和密碼登錄
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// 獲取 / 路徑下的檔案列表
$buff ftp_rawlist($conn_id'/');

// 關閉連線
ftp_close($conn_id);

// 輸出
var_dump($buff);
?>

以上例程的輸出類似於:

array(3) {
  [0]=>
  string(65) "drwxr-x---   3 vincent  vincent      4096 Jul 12 12:16 public_ftp"
  [1]=>
  string(66) "drwxr-x---  15 vincent  vincent      4096 Nov  3 21:31 public_html"
  [2]=>
  string(73) "lrwxrwxrwx   1 vincent  vincent        11 Jul 12 12:16 www -> public_html"
}

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *