this snippet will give you informations about a file like size, last modified
date and more
“file informations” makes use of the built-in PHP functions
round( ),
stat( ) and
date( ).
01 <?php
02
03 function nice_size($fs)
04 {
05 if ($fs >= 1073741824)
06 $fs = round(($fs / 1073741824 * 100) / 100).' Gb';
07 elseif ($fs >= 1048576)
08 $fs = round(($fs / 1048576 * 100) / 100).' Mb';
09 elseif ($fs >= 1024)
10 $fs = round(($fs / 1024 * 100) / 100).' Kb';
11 else
12 $fs = $fs .' b';
13 return $fs;
14 }
15
16 // $file_stats = stat('path/to/file/');
17 $file_stats = stat(__file__); // demo
18
19 echo '
20 <p>
21 filesize: '.nice_size($file_stats[7]).'<br />
22 last access: '.date('l, F dS 20y - H:i:s',$file_stats[8]).'<br />
23 last modified: '.date('l, F dS 20y - H:i:s',$file_stats[9]).'
24 </p>';
25
26 ?>