Php methods for obtaining file types and information
|
This document describes how to obtain file types and information by using php. Share it with you for your reference. The specific implementation method is as follows:
- $ File = "php.txt ";
- // Open the file. r indicates that the file is read-only.
- $ Handle = fopen ($ file, "r ");
- // Obtain the statistics of the file
- $ Fstat = fstat ($ handle );
- Echo "file name:". basename ($ file )."
";
- // Echo "file size:". round (filesize ("$ file")/). "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 Modification time:". date ("Y-m-d h: I: s", filemtime ($ file ))."
";
- Echo "last Modification time:". date ("Y-m-d h: I: s", $ fstat ["mtime"]);
- ?>
I hope this article will help you with php programming. |
Php