Categorie

Dimensioni del file funzione

Questo esempio mostra come formattare un file e presentare la sua dimensione migliore

<? Php
funzione format_size ($ file)
(
/ / Trova la dimensione del file del file
$ Get_file_size = filesize ($ file);
/ / Se la dimensione del file è uno tra i 7 9 caratteri allora la sua in Mb
if (strlen ($ get_file_size) <= 9 & & strlen ($ get_file_size)> = 7)
(
$ Get_file_size = number_format ($ get_file_size / 1048576,1);
ritorno "$ get_file_size MB";
)
/ / 10 caratteri o più di mezzo Gb
elseif (strlen ($ get_file_size)> = 10)
(
$ Get_file_size = number_format ($ get_file_size / 1073741824,1);
ritorno "$ get_file_size GB";
)
/ / Ogni altra cosa è kilobyte
altro
(
$ Get_file_size = number_format ($ get_file_size / 1024,1);
ritorno "$ get_file_size KB";
)
)
?>

Uso
<? Php

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

Nessun post.

Related posts portato a voi da Yet Another Related Posts Plugin .

Lasci una risposta

È possibile utilizzare questi tag 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
Aggiorna Image