挺简单的一个文件,耗时一两个小时看UIkit文档以及熟悉了下php的相关函数,该文件配合伪静态规则可以实现通过浏览器查看下载文件。UIkit好看。
<?php $files; class fileinfo { public $filename; } $handler = opendir(__DIR__); while(($filename=readdir($handler))==true){ if($filename=="." || $filename=="..")continue; $temp=new fileinfo(); $temp->filename=$filename; $temp->filedate=date('r',filemtime(getcwd().'/'.$filename)); $temp->filesize=filesize(getcwd().'/'.$filename); $files[]=$temp; } closedir($handler); echo '<div class="uk-card uk-card-body uk-card-default" style="margin:20px"><table class="uk-table uk-table-divider"> <thead> <tr> <th>文件名</th> <th>修改时间</th> <th>文件大小</th> </tr> </thead> <tbody>'; echo '<tr><td><a class="" href="../">..</a><br></td><td></td><td></td></tr>'; foreach($files as $fileinfo){ echo'<tr>'; echo '<td><a class="" href="'.$fileinfo->filename.'">'.$fileinfo->filename.'</a></td>'; echo '<td>'.$fileinfo->filedate.'</td>'; echo '<td>'.$fileinfo->filesize.'bytes</td>'; echo'</tr>'; } echo ' </tbody> </table></div>'; echo '<!-- UIkit CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.3/css/uikit.min.css" /> <!-- UIkit JS --> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.3/js/uikit.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.3/js/uikit-icons.min.js"></script>'; ?>