我想获取驻留在远程服务器上的目录的属性或大小,因此路径必须包含 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