Kanske inte den snyggaste koden, men den fungerar:
Kod:
<?php
$realpath = dirname( __FILE__ ) .'/';
if( isset( $_GET['path'] ) )
{
$path = str_replace( '.', '', $_GET['path'] );
if( is_dir( $realpath . $path ) )
{
$realpath .= $path;
$realpath = rtrim( $realpath, '/' ) .'/';
}
}
foreach( glob( $realpath .'*' ) as $file )
{
$file = str_replace( dirname( __FILE__ ) .'/', '', $file );
if( is_dir( $file ) )
{
echo '<a href="files.php?path='. $file .'">'. $file .'<br />';
}
else
{
echo '<a href="'. $file .'">'. substr( $file, 0, strrpos( $file, '.' ) ) .'<br />';
}
}
?>
Förutsätter att filen du lägger koden i heter files.php.