If you want to build an online file management system, you must first know how to read directories and files. In fact, this function can be implemented with just a few lines of code.
Output effect:
Implementation code:
Copy code The code is as follows:
php
$dir = "D:/"; //The directory to be obtained
echo "************ Get all files and folders in the directory************ ***
";
//First determine whether the specified path is a folder
if (is_dir($dir)){
if ($dh = opendir($dir )){
while (($file = readdir($dh))!= false){
//The full path of the file name includes the file name
$filePath = $dir.$file;
//Get the file modification time
$fmt = filemtime($filePath);
echo "(".date("Y-m-d H:i:s" ,$fmt).") ".$filePath."
";
}
closedir($dh);
}
}
?>
This is just the most basic effect. Once you understand it, it is easy to make other requirements.
http://www.bkjia.com/PHPjc/768129.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/768129.htmlTechArticleIf you want to build an online file management system, you must first know how to read directories and files. In fact, this function This can be achieved with just a few lines of code. Output effect: Implementation code...