I want to get the properties or just size of the directory that resides on a remote server, so the path must consist of IP/Virtual Directory/Data Repository
http://192.169.1.5/MyVirtualDir/MyData/
I'v tried it with curl and 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
精彩评论