Categorias

Arquivo função do tamanho

Este exemplo mostra como formatar um arquivo e apresentar o seu tamanho melhor

<? Php
format_size função ($ arquivo)
(
/ / Encontrar o tamanho do arquivo do arquivo
$ Get_file_size = filesize ($ arquivo);
/ / Se o tamanho do arquivo tem entre 7 um 9 caracteres, em seguida, em seu Mb
if (strlen ($ get_file_size) <= 9 & & strlen ($ get_file_size)> = 7)
(
$ Get_file_size = number_format ($ get_file_size / 1048576,1);
return "$ get_file_size MB";
)
/ / 10 caracteres ou mais meios Gb
elseif (strlen ($ get_file_size)> = 10)
(
$ Get_file_size = number_format ($ get_file_size / 1073741824,1);
return "$ get_file_size GB";
)
/ / Qualquer outra coisa é kilobytes
outro
(
$ Get_file_size = number_format ($ get_file_size / 1024,1);
return "$ get_file_size KB";
)
)
?>

Uso
<? Php

format_size echo ("index.htm");
echo "<br>";
echo format_size (monthimages.zip ");
echo "<br>";
echo format_size (sampledb.mdb ");
?>

Não há mensagens relacionadas.

Lugares ligados trazido a você por Yet Another Related Posts Plugin .

Deixe uma resposta

Você pode usar essas tags HTML

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA Image CAPTCHA Audio
Atualizar Imagem