This article describes how to implement autoindex on a php simulated server. The example analyzes php URL operations and passing parameters. It has some reference value. For more information, see
This article describes how to implement autoindex on a php simulated server. The example analyzes php URL operations and passing parameters. It has some reference value. For more information, see
This article describes how to implement autoindex on a php simulated server. Share it with you for your reference. The specific implementation method is as follows:
1. the PHP code is as follows:
The Code is as follows:
<? Php
// File Browser
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 <? Php echo $ pwd?>
Pwd of <? Php echo $ pwd?>
">../
<?php
foreach ($it as $file){
if($file->isDir()) {
$fileSize = '_';
$fileName = $file->getFilename() . 'http://www.jb51.net/';
} elseif($file->isFile()) {
$fileSize = $file->getSize();
$fileName = $file->getFilename();
}
$date = date('Y-m-d H:i',$file->getCTime());
?>getRealPath()?>"><?php echo $fileName ?><?php echo str_pad($date, 60-strlen($fileName),' ',STR_PAD_LEFT)?><?php echo str_pad($fileSize,30,' ',STR_PAD_LEFT)?>
<?php }?>
2. Shows the running effect:
I hope this article will help you with php programming.
,