communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "file handling" - download "file informations" - open demo of "file informations"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

file handling - file informations was created/last modified on Sun 18 Apr 2004 8:49 PM

this snippet will give you informations about a file like size, last modified date and more
   
<?php
   
function ConvertSize($fs)
{
     if (
$fs >= 1073741824)
      
$fs = round($fs / 1073741824 * 100) / 100 . " Gb";
     elseif (
$fs >= 1048576)
      
$fs = round($fs / 1048576 * 100) / 100 . " Mb";
     elseif (
$fs >= 1024)
      
$fs = round($fs / 1024 * 100) / 100 . " Kb";
     else
      
$fs = $fs . " b";
     return
$fs;
}
    
// $fil_array = stat('path/to/file/');
$fil_array = stat(__file__); // demo
    
echo 'filesize: '.ConvertSize($fil_array[7]).'<br>';
echo
'last access: '.date('l, F dS 20y - H:i:s',$fil_array[8]).'<br>';
echo
'last modified: '.date('l, F dS 20y - H:i:s',$fil_array[9]).'<br>';
   
?>
   

learn more about some of the PHP functions used in this snippet: array, date, echo, else, elseif, file, filesize, for, function, return, round, stat

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

PHParadise.com - PHP-classes.org - your site on safari