Php simulates the method of implementing autoindex on the server, phpautoindex. Php simulated server autoindex effect method. phpautoindex this article describes how php simulated server achieves autoindex effect. Share it with you for your reference. The specific implementation method is php simulating the server's autoindex effect, phpautoindex
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() . '/';
} 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.
Examples in this article describes how to simulate a php server to achieve autoindex. Share it with you for your reference. Implementation...