kan iemand mij helpen ? ik heb een php script gemaakt. het gaat over dir uitlezen en linken. het is mij gelukt. maar de inhoud van de mappen wordt niet gelinkt. maar de mappen wordt wel automatische gelinkt. ik wil graag dat de bestanden in de map ook automatiche gelinkt worden.

hier is het script!

<?php
// show directory content
function showDir($dir, $i, $maxDepth){
$i++;
if($checkDir = opendir($dir)){
$cDir = 0;
$cFile = 0;
// check all files in $dir, add to array listDir or listFile
while($file = readdir($checkDir)){
if($file != "." && $file != ".."){
if(is_dir($dir . "/" . $file)){
$listDir[$cDir] = $file;
$cDir++;
}
else{
$listFile[$cFile] = $file;
$cFile++;
}
}
}

// show directories
if(count($listDir) > 0){
sort($listDir);
for($j = 0; $j < count($listDir); $j++){
echo "
<tr>";
$spacer = "";
for($l = 0; $l < $i; $l++) $spacer .= "&emsp;";
// create link
$link = "<a href=\"" . $_SERVER["PHP_SELF"] . "?dir=" . $dir . "/" . $listDir[$j] . "\">$listDir[$j]</a>";
echo "<td>" . $spacer . $link . "</td>
</tr>";
// list all subdirectories up to maxDepth
if($i < $maxDepth) showDir($dir . "/" . $listDir[$j], $i, $maxDepth);
}
}

// show files
if(count($listFile) > 0){
sort($listFile);
for($k = 0; $k < count($listFile); $k++){
echo "
<tr>";
$spacer = "";
for($l = 0; $l < $i; $l++) $spacer .= "&emsp;";
// create link
$link = "<a href=\"" . "?file=" . $file . "\">$listFile[$k]</a>";
echo "<td>" . $link . $spacer . $listFile[$k] . "</td>
</tr>";

}
}
closedir($checkDir);
}
}

if($_GET["dir"] == "" || !is_dir($_GET["dir"])) $dir = getcwd();
else $dir = $_GET["dir"];
// replace backslashes, not necessary, but better to look at
$dir = str_replace("\\", "/", $dir);

// show parent path
$pDir = pathinfo($dir);
$parentDir = $pDir["dirname"];

echo "<a href=\"" . $_SERVER["PHP_SELF"] . "\"><h3>Home</h3></a>";


// Display directory content
echo"<table border=1 cellspacing=0 cellpadding=2>
<tr><th align=left>File / Dir</th>";

// specifies the maxDepth of included subdirectories
// set maxDepth to 0 if u want to display the current directory
$maxDepth = 0;
showDir($dir, -1, $maxDepth);
?>
Leuke functie heb je gemaakt, ik weet zo geen oplossing op jouw probleem. Maar graag zou ik willen weten hoe je de directory kan aanpassen naar je eigen gespecificeerde patch.

Ik weet dat je hem mee geeft als paramater. Maar hoe roep je dit aan ?
Kun je boven in de fucntie het beste $dir = "../user/info/"; in typen ?

Reageren