This is the web log of Tim Bennett, web designer. He also runs Texelate, offering the best web design Leeds, Yorkshire has to offer

Getting file information with PHP

Sunday, May 28th, 2006 at 8:16 am

Not much explanation needed here:

<?php

 

    $file = “yourfilegoeshere.php”;

 

    $fileinfo = stat( $file );

    

    echo “File name: ” . $file . “<br />\t”;

    echo “File type: .” . substr( strrchr( $file, “.” ), 1 ) . “<br />\n”;

    echo “Filesize: ” . round( ( $fileinfo[ "size" ] / 1024 ), 1 )  . “k<br />\n”; //  size in bytes 

    echo “Last accessed: ” . date( “H:i:s, d/m/y”, $fileinfo[ "atime" ] ) . “<br />\n”; //  time of last access (Unix timestamp) 

    echo “Last Modified: ” . date( “H:i:s, d/m/y”, $fileinfo[ "mtime" ] ) . “<br />\n”; //  time of last modification (Unix timestamp) 

 

?>

Leave a Reply

You must be logged in to post a comment. If you don't have an account register one now.

Do you need a website or web-related service?
I run an award-winning web design studio.