Les avertissements suivants se sont produits :
Warning [2] Undefined array key 0 - Line: 1640 - File: showthread.php PHP 8.2.18 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 1640 errorHandler->error_callback
/showthread.php 915 buildtree




Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
Lister le contenu d'un dossier
#2
bonjour,
tu peux t'inspirer de ça dans une balise utilisateur.
Code :
global $gCms;
$config =& $gCms->GetConfig();
$realpath=$config["uploads_path"]."/".$params['doc'];
$urlpath=$config["uploads_url"]."/".$params['doc'];
$dir=@opendir($realpath);

        if (!$dir) echo "Dossier introuvable";

while ($file=readdir($dir)) {
$full_name=$realpath."/".$file; //nom complet
    if ($file=="." || $file==".." || $file[0]=="." || substr($file,0,6)=="thumb_" || is_dir($full_name)) continue;

$info=array();
$info["name"]=$file;
$statinfo=stat($full_name); //recup des stats sur le fichier
                        $info["size"]=$statinfo["size"];        
            $info["date"]=$statinfo["mtime"];
            $info["url"]=$urlpath."/".$file;
            $explodedfile=explode('.', $file);
            $info["ext"]=array_pop($explodedfile);
            $info["fileinfo"]=GetFileInfo($full_name,$info["ext"],false);

if (!in_array(strtolower($info["ext"]),array("doc","xls","pdf","ppt"))) continue; // on filtre les extensions
if (file_exists($config["root_path"]."/modules/FileManager/icons/themes/default/extensions/32px/".strtolower($info["ext"]).".png")) {
            $image="<img  style='border:0;' src='".$config["root_url"]."/modules/FileManager/icons/themes/default/extensions/32px/".strtolower($info["ext"]).".png' alt='fichier-".$info["ext"]."' title='fichier-".$info["ext"]."' align='absmiddle' />";
        } else {
            
            $image="<img  style='border:0;' src='".$config["root_url"]."/modules/FileManager/icons/themes/default/extensions/32px/0.png' alt='fichier-".$info["ext"]."' title='fichier-".$info["ext"]."' align='absmiddle' />";
        }
echo "<p><a href='".$info["url"]."' >".$image."&nbsp;".implode(".", $explodedfile)."</a></p>";


}
Le parametre 'doc' est le no du dossier à lister qui est dans uploads.
{SEO}
Inscrivez-vous à notre Newsletter sur le site (colonne de droite, en bas).
Vous appréciez CMSMS et l'aide qui vous est fournie ici, aidez-nous en participant au projet.
Formation CMS Made Simple | Création de site CMS Made Simple.

C'est en se plantant qu'on devient cultivé.
J'ai un string dans l'Array (Paris Hilton)
Répondre


Messages dans ce sujet

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)