Ich weiß zwar nicht ob du CURL hast aber hier ein Beispiel solltest du CURL Extension haben.
/include/contents/downloads.php Line 48
function get_download_size($file) {
$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
$size = @filesize($file); if ($size == 0) { return('n/a'); } else {
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); }
}
in
function get_download_size($file) {
$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
$size = @filesize($file);
if ($size == 0) {
if (extension_loaded('curl')) {
$ch = curl_init($file);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
return 'n/a';
}
else {
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$contentLength = (int)$matches[1];
}
}
return (round($contentLength/pow(1024, ($i = floor(log($contentLength, 1024)))), 2) . $sizes[$i]);
}
}
else { return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); }
}
Zuletzt modifiziert von she am 12.12.2010 - 21:42:50