However, let's say the file has 800Mbs, so what happens is that it shows a value a little lower, like 792Mbs, not its exact value. I would like to know how I can fix this error in the code below, since I already thank the help of all.
<?php
function tamanho_arquivo($arquivo) {
$tamanhoarquivo = filesize($arquivo);
/* Medidas */
$medidas = array('KB', 'MB', 'GB', 'TB');
/* Se for menor que 1KB arredonda para 1KB */
if($tamanhoarquivo < 999){
$tamanhoarquivo = 1000;
}
for ($i = 0; $tamanhoarquivo > 999; $i++){
$tamanhoarquivo /= 1024;
}
return round($tamanhoarquivo) . $medidas[$i - 1];
}
// tamanho do arquivo 800Mbs
echo tamanho_arquivo('filme.avi');
?>
I have a problem with this type code I have a dedicated and I used this function to show the size of the file and add the value in the SQL in my dedicated worked only that my friend's dedicated one is giving error on line 2 in $ filefile = filesize ($ file);
Warning: filesize () [function.filesize]: stat failed for ../driver/rar/documento1.rar in /home/meusite/public_html/adm/additional.php on line 49 line 49 in case and where this function above starts and integrates with my item adding code.
Note: line 49 and $ filefile = filesize ($ file);
Could anyone help me fix this?
Bruno has already helped me to fix the code to put the exact size with everything I am not intending the reason to be giving this error.