Get File Name, Size, Last Access Time And Modified Time

 
<?php   function tstamp_to_date($tstamp) {
      return date("m-d-y  g:i:sa", $tstamp);
   }   $file = "/data.txt";
   $fh = fopen($file, "r");   $fileinfo = fstat($fh);   echo "Filename: ".basename($file)."<br />";
   echo "Filesize: ".round(($fileinfo["size"]/1024), 2)." kb <br />";
   echo "Last accessed: ".tstamp_to_date($fileinfo["atime"])."<br />";
   echo "Last modified: ".tstamp_to_date($fileinfo["mtime"])."<br />";
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.