簡體   English   中英

使用CURL和PHP通過FTP從遠程站點的根目錄中獲取目錄和文件的列表

[英]Getting a list of directories and files from root directory from remote site via FTP using CURL and PHP

我目前從var_dump中得到錯誤的結果。 有什么方法可以從FTP帳戶獲取根目錄下的文件夾和文件的結果。

 <?php

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "ftp://www.xxxx.co.uk");
curl_setopt($ch, CURLOPT_USERPWD, "[xxxx]:[xxxx]");
// grab URL and pass it to the browser
$result = curl_exec($ch);
var_dump($result);
// close cURL resource, and free up system resources
curl_close($ch);

?>

你為什么不使用ftp_connect

$ftp = ftp_connect("ftp.xxxx.co.uk") or die('could not connect.');
$raw = ftp_login($ftp, "anonymous", "") or die('could not login.');
$raw = ftp_pasv($ftp, true) or die('could not enable passive mode.');
$raw = ftp_rawlist($ftp, "/public_html/");
var_dump($raw);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM