check if a folder contains images of any types in php -


i know if possible check in given folder whether contains images of types.

for example : folder location /var/www/html/project/images/

i want check in images folder, if contains images in it...

it can have following types .jpeg, .jpg, .png, .gif

there no name images.

glob can used problem. glob function can find pathnames matches pattern, similar regex. here's sample code search jpg, png, , gif files in folder , echo out names of these files.

<?php $path = '/var/www/html/project/images/'; $files = glob($path."*.{jpg,jpeg,png,gif}", glob_brace); print_r($files); ?> 

if want check whether there images or not, use following code instead of print_r($files);:

if (!empty($files)) {     echo 'there images in folder'; } else {     echo "no images found here";  } ?> 

if want know more recursively checking directories, check out readdir


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -