Ciao, girando in rete ho trovato questa soluzione, non l'ho provata quindi non posso giurare sulla sua efficacia, ma fa al caso tuo.
Codice PHP:
function formatbytes($file, $type)
{
switch($type){
case "KB":
$filesize = filesize($file) * .0009765625; // bytes to KB
break;
case "MB":
$filesize = (filesize($file) * .0009765625) * .0009765625; // bytes to MB
break;
case "GB":
$filesize = ((filesize($file) * .0009765625) * .0009765625) * .0009765625; // bytes to GB
break;
}
if($filesize <= 0){
return $filesize = 'unknown file size';}
else{return round($filesize, 2).' '.$type;}
}
// USAGE
echo formatbytes("$_SERVER[DOCUMENT_ROOT]/images/large_picture.jpg", "MB");
// would display the file size in MB
Spero ti sia d'aiuto