Php 远程服务器上虚拟目录的目录大小

Php 远程服务器上虚拟目录的目录大小,php,curl,Php,Curl,我想获取驻留在远程服务器上的目录的属性或大小,因此路径必须由 IP/虚拟目录/数据存储库 http://192.169.1.5/MyVirtualDir/MyData/ 我已经用curl和php试过了 $remoteFile = "192.168.1.5/MyVirtualDir/MyData/"; $ch = curl_init($remoteFile); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT

我想获取驻留在远程服务器上的目录的属性或大小,因此路径必须由 IP/虚拟目录/数据存储库

http://192.169.1.5/MyVirtualDir/MyData/
我已经用curl和php试过了

    $remoteFile = "192.168.1.5/MyVirtualDir/MyData/";
$ch = curl_init($remoteFile);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //not
$data = curl_exec($ch); curl_close($ch); if ($data === false) { echo 'cURL failed'; exit; }

$contentLength = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
  $status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
  $contentLength = (int)$matches[1];
}

echo 'HTTP Status: ' . $status . "\n";
echo 'Content-Length: ' . $contentLength;


ERROR:scandir() [function.scandir]: connect() failed: No connection could be made because the target machine actively refused it

那是什么样的服务器?windows/samba网络共享?还是HTTP服务器?您需要知道curl主要用于HTTP/FTP。所以你可能只是在你的问题上抛出了一些完全不同的代码。为什么你认为它能解决你的问题?你不能这么做。不允许您知道此目录中的每个文件。。。如果有一些文件您没有查看它们的权限怎么办?如何计算但是,请看一下以下说明: