2016-04-12 38 views

回答

0

您可以使用filesize()來獲取圖像的文件大小。

返回文件的大小(以字節爲單位)或FALSE(並生成E_WARNING級別的錯誤)以防萬一發生錯誤。

$filename = "Koala.jpg"; 

$size = filesize($filename) . ' B'; 

$size = number_format($size/1024, 2) . ' KB'; 

這將在千回的圖像文件的大小。


如果你只知道網址,你可以使用get_headers():從http://www.w3bees.com/2013/03/get-remote-file-size-using-php.html引用

function remote_file_size($url){ 
    $data = get_headers($url, true); 
    if (isset($data['Content-Length'])) 
    return (int) $data['Content-Length']; 
} 

echo remote_file_size('http://example.com/image.png'); 

方法。

+0

但我只知道網址 – Barba

相關問題