Home  >  Article  >  Backend Development  >  How to get file type and file information in php, _PHP tutorial

How to get file type and file information in php, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:46:50806browse

How to obtain file type and file information in php,

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:

<&#63;php
$file = "php.txt";
//打开文件,r表示以只读方式打开
$handle = fopen($file,"r");
//获取文件的统计信息
$fstat = fstat($handle);
echo "文件名:".basename($file)."<br>";
//echo "文件大小:".round(filesize("$file")/1024,2)."kb<br>";
echo "文件大小:".round($fstat["size"]/1024,2)."kb<br>";
//echo "最后访问时间:".date("Y-m-d h:i:s",fileatime($file))."<br>";
echo "最后访问时间:".date("Y-m-d h:i:s",$fstat["atime"])."<br>";
//echo "最后修改时间:".date("Y-m-d h:i:s",filemtime($file))."<br>";
echo "最后修改时间:".date("Y-m-d h:i:s",$fstat["mtime"]);
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1030142.htmlTechArticleHow to obtain file type and file information in php. 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: p...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn