function recurse_dir($DIR)
{
if ($ODIR = opendir($DIR))
{
while ($FILE = readdir($ODIR))
{
if ( ($FILE != ".") && ($FILE != "..") )
{
$TMP = $DIR."/".$FILE ;
if($FILE != '')
{
if(is_dir($TMP))
{
$DIR1 .= '<option value="?o=galerietestr=&'.$TMP.'">'.$TMP.'</option>';
$DIR1 .= recurse_dir ($TMP) ;
}
}
}
}
closedir($ODIR);
return $DIR1;
}
}
//--> Afficher la listre déroulante
echo '<select onChange="location = this.options[this.selectedIndex].value;" >';
echo recurse_dir('galerie');
echo '</select>';Code : Tout sélectionner
ex : /Galerie -> repertoire de base de la galerie
/Galerie/vacances2006 -> sous repertoire de niveau 1
/Galerie/vacances2006/annecy -> sous repertoire de niveau 2Code : Tout sélectionner
function galerie ($a) {
$url= "galerie/".$_GET['r'];
$rep=opendir($url);
$d=$_GET['c'];
$a=$url .'/' . $_GET['c'];
$dimg=opendir($a);
while(false !== ($fichier = readdir($rep))) {
if ($fichier != "." && $fichier != "..") {
$dname[] = $fichier;
sort($dname);
reset ($dname);
}
}Code : Tout sélectionner
<select onChange="location = this.options[this.selectedIndex].value;">
<option>choix</option>
<?
$u=0;
foreach($dname as $key=>$val) {
if($dname[$u]){
print " \t\t\t<option value=\"?o=galerie&r=" . $_GET[r] . "&c=" . $dname[$u] . "\">" . $dname[$u] . "</option>\n";
$u++;
}
}
?>
</select>$repertoire = (isset($_GET['r']))?$_GET['r']:"";
$sous_rep = (isset($_GET['c']))?$_GET['c']:"";
$car_forbid = array('.','/');
$repertoire = str_replace($car_forbid, "", $repertoire);
$sous_rep = str_replace($car_forbid, "", $sous_rep);
$url = "./galerie/".$repertoire."/" ;
$url .= ($sous_rep != "")?$sous_rep.'/':"";
Ensuite tu test si le repertoire existe bien avant de l'ouvrir (opendir() ).if(is_dir($url))Code : Tout sélectionner
$repertoire = (isset($_GET['r']))?$_GET['r']:"";
$sous_rep = (isset($_GET['c']))?$_GET['c']:"";
$car_forbid = array('.','/');
$repertoire = str_replace($car_forbid, "", $repertoire);
$sous_rep = str_replace($car_forbid, "", $sous_rep);
$url = "./galerie/".$repertoire."/" ;
$url .= ($sous_rep != "")?$sous_rep.'/':"";
$rep=opendir($url);
$d=$_GET['c'];
$a=$url .'/' . $_GET['c'];
$dimg=opendir($a);
while(false !== ($fichier = readdir($rep))) {
if ($fichier != "." && $fichier != "..") {
$dname[] = $fichier;
sort($dname);
reset ($dname);
}
}