Directories
- Installing/Configuring
- Predefined Constants
- Directory — The Directory class
- Directory::close — Close directory handle
- Directory::read — Read entry from directory handle
- Directory::rewind — Rewind directory handle
- Directory Functions
- chdir — Change directory
- chroot — Change the root directory
- closedir — Close directory handle
- dir — Return an instance of the Directory class
- getcwd — Gets the current working directory
- opendir — Open directory handle
- readdir — Read entry from directory handle
- rewinddir — Rewind directory handle
- scandir — List files and directories inside the specified path
Коментарии
<form id="browserform" action="browser.php" method="post">
<?php
$rootpath='';
if(isset($_POST['rootpath']))
$rootpath=$_POST['rootpath'];
?>
<input type="text" id="rootpath" name="rootpath" value="<?php echo $rootpath;?>" />
<?php
$handle=opendir($rootpath);
if($handle!=null)
while (false !== ($entry = readdir($handle))) {
if(is_dir($rootpath."/".$entry))
echo "<a href='#' onclick='opendir(\"$entry\")'>$entry</a><br>";
else
echo "<a href='#' onclick='openfile(\"$entry\")'>$entry</a><br>";
}
?>
</form>
<script type="text/javascript">
function opendir(dir)
{
if(dir=="..")
{
var path=document.getElementById("rootpath").value;
var arr=path.split("/");
path=arr[0];
for(var i=1;i<arr.length-1;i++)
path+="/"+arr[i];
document.getElementById("rootpath").value=path;
browserform.submit();
}
else
{
document.getElementById("rootpath").value+="/"+dir;
browserform.submit();
}
}
function openfile(dir)
{
var path=document.getElementById("rootpath").value;
window.open("player.php?path="+path+"/"+dir);
}
</script>