Php get specific type of files from folder

by Mohan 2013-11-25 19:12:13



Hai,

To get only particular type of files (jpg or png or gif) from a folder, the following code can be used,




foreach(glob('multimedia/{*.jpg,*.gif,*.png}', GLOB_BRACE) as $image)
{
echo "Filename: " . $image . "<br />";
}



will display as


Filename: multimedia/test.jpg
Filename: multimedia/test3.png
Filename: multimedia/test2.jpg
Filename: multimedia/test4.gif

Tagged in:

627
like
0
dislike
0
mail
flag

You must LOGIN to add comments