Last active
August 29, 2015 13:57
-
-
Save wuliupo/9702209 to your computer and use it in GitHub Desktop.
list files under data folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<title>文件列表</title> | |
<meta charset="UTF-8" /> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> | |
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" name="viewport" /> | |
<link rel="stylesheet" type="text/css" href="../../common/css/bootstrap.min.css" /> | |
<style type="text/css"> | |
@media screen and (max-width:600px) { | |
ul {padding-left: 10px;} | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1 class="well">文件列表</h1> | |
<ul> | |
<?php | |
function listFile($dirName){ | |
$list=array(); | |
$dh = opendir($dirName); | |
while(($file = readdir($dh)) !== false){ | |
if($file != '.' && $file != '..'){ | |
$list[]=$file; | |
} | |
} | |
closedir($dh); | |
return $list; | |
} | |
$dirName='data/'; | |
$list=listFile($dirName); | |
rsort($list); | |
foreach($list as $file){ | |
$path=$dirName.$file; | |
echo '<li>'. date('Y-m-d H:i:s', filemtime($path)).' <a target="_blank" href="'.$path.'">'.$file.'</a></li>'; | |
echo '<pre>'.htmlspecialchars(file_get_contents($path)).'</pre>'; | |
} | |
?> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment