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

时间:2011-10-11 15:46:56

标签: 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_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

0 个答案:

没有答案
相关问题