Write the below code to read filse name from an particular folder.
function dirFiles($directry) {
$dir = dir($directry); //Open Directory
while (false!== ($file = $dir->read())) //Reads Directory
{
$extension = substr($file, strrpos($file, '.')); // Gets the File Extension
if($extension == ".xml" || $extension == ".csv" || $extension == ".php" |$extension == ".txt") // Extensions Allowed
$filesall[$file] = $file; // Store in Array
}
$dir->close(); // Close Directory
asort($filesall); // Sorts the Array
return $filesall;
}
$array = dirFiles('/home/your absolute directory/');
foreach ($array as $key => $file)
{
echo $file; // Display Images
echo '<br />';
}
No comments:
Post a Comment