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 />";
?>
Related examples in the same category