Home > php教程 > php手册 > body text

php模拟服务器实现autoindex效果的方法

WBOY
Release: 2016-06-06 20:06:57
Original
1500 people have browsed it

这篇文章主要介绍了php模拟服务器实现autoindex效果的方法,实例分析了php操作URL及传递参数的技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了php模拟服务器实现autoindex效果的方法。分享给大家供大家参考。具体实现方法如下:

1.PHP代码如下:

复制代码 代码如下:

//文件浏览程序
error_reporting(0);
$pwd = empty($_GET['dir']) ? './' : $_GET['dir'];
$pwd = realpath($pwd);
if(is_file($pwd)) {
    highlight_file ($pwd);
    exit;
}else
    $it = new FilesystemIterator($pwd);
?>


    pwd of


   

pwd of



   
<a href="?dir=<?php%20echo%20dirname(%24pwd)?>">../</a><br>

foreach ($it as $file){ <br>
    if($file->isDir()) {<br>
        $fileSize = '_';<br>
        $fileName = $file->getFilename() . 'http://www.jb51.net/';<br>
    } elseif($file->isFile()) {<br>
        $fileSize =  $file->getSize();<br>
        $fileName = $file->getFilename();<br>
    }<br>
    $date = date('Y-m-d H:i',$file->getCTime());<br>
?><a href="?dir=<?php%20echo%20%24file->getRealPath()?>"></a><br>
Copy after login



2. 运行效果如下图所示:

php模拟服务器实现autoindex效果的方法

php模拟服务器实现autoindex效果的方法

希望本文所述对大家的php程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!