1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nouvelle page 1</title>
</head>
<body>
<table>
<?php
function browse($pDirectory, $pExtension)
{
if($handle = opendir($pDirectory))
{
while(false !== ($file = readdir($handle)))
{
$getExt = explode(".", $file);
$countExt = count($getExt);
$fExt = $countExt - 1;
$myExt = $getExt[$fExt];
if (($myExt == $pExtension) && ($file != ".") && ($file != ".."))
{$files[] = $file;}
}
}
return $files;
closedir($handle);
}
$gDirectory = "mon_chemin"; // à éditer
$gExtension = "doc xls zip txt rar"; // séparez les extensions par un espace
$ExpExt = explode(" ", $gExtension);
sort ($ExpExt);
foreach ($ExpExt as $findExt)
{
$getFile = @browse($gDirectory, $findExt);
$countFile = count($getFile);
echo "<b>Fichier(s) ".strtoupper($findExt)."</b> (".$countFile.")<br>";
if ($countFile != 0)
{ foreach ($getFile as $myFile) {echo "<a target='_blank' href='http/mon_url/$myFile'>".$myFile."<br>";} }
else
{ echo "- Aucun fichier ".$findExt." trouvé<br>"; }
echo "<br>";
}
?> </table>
</body>
</html> |
Partager