You can use the following PHP code sequence, saved in a file named index.php (loaded in the folder whose contents you want to display):
<?php
$basepath = realpath("./"); // Root directory
$path = realpath($basepath.$_GET["path"]); // Requested path
$relativepath = "./".substr_replace( $path, "", 0, strlen( $basepath ) );
if( "/" == substr( $relativepath, -1 )) { // Remove the trailing slash
$relativepath = substr( $relativepath, 0, -1 );
}
$dh = opendir( $path );
while( false !== ($file = readdir( $dh ))) {
if("." == $file) {continue;}
// converts the filename to utf8
$file_utf8 = iconv( "iso-8859-1", "utf-8", $file );
// encode the path ('path' part: already utf8; 'filename' part: still iso-8859-1)
$link = str_replace( "%2F", "/", rawurlencode( "{$relativepath}/" )) . rawurlencode( utf8_decode( "{$file_utf8}" ));
if( is_dir( "{$path}/{$file}" )) {
echo "<a href=\"?path={$link}\">{$file_utf8}</a><br/>";
} else {
echo "<a href=\"{$link}\">{$file_utf8}</a><br/>";
}
}
?>
