Top
Home

Files in Directroy

Listing files in a directory



<?php
$dirPath = dir('../wp-content/plugins/Moose_Fade/slides/');
$imgArray = array();
while (($file = $dirPath->read()) !== false)
{
if ((substr($file, -3)=="gif") || (substr($file, -3)=="jpg") || (substr($file, -3)=="png"))
{
$imgArray[ ] = trim($file);
}
}
$dirPath->close();
sort($imgArray);
$c = count($imgArray);
for($i=0; $i<$c; $i++)
{
echo "<option value="" . $imgArray[$i] . ""> " . $imgArray[$i] . "n";
}
?>