The example in this article describes the method of obtaining file type and file information in PHP. Share it with everyone for your reference. The specific implementation method is as follows:
-
- $file = "php.txt";
- //Open the file, r means open in read-only mode
- $handle = fopen($file,"r");
- //Get File statistics
- $fstat = fstat($handle);
- echo "File name: ".basename($file)."
";
- //echo "File size: ".round(filesize(" $file")/1024,2)."kb
";
- echo "File size:".round($fstat["size"]/1024,2)."kb
";
- // echo "Last access time:".date("Y-m-d h:i:s",fileatime($file))."
";
- echo "Last access time:".date("Y-m-d h:i: s",$fstat["atime"])."
";
- //echo "Last modified time:".date("Y-m-d h:i:s",filemtime($file))."< ;br>";
- echo "Last modified time:".date("Y-m-d h:i:s",$fstat["mtime"]);
- ?>
-
-
Copy code
I hope this article will be helpful to everyone’s PHP programming design.
|