all the images which stored in sub direcories of one main directory
from database.
like one main directory contains few sub folders which dynamically created when i upload a file/image to db
so i want to retrive all the images which store in those sub directories by giving path up to main folder
but unfortunately its not working, it works only when i give full path to one sub folder
as shown in below code
<?php
$imagesDirectory = "or_attachments/29246066441/45/";
if(is_dir($imagesDirectory))
{
$opendirectory = opendir($imagesDirectory);
while (($image = readdir($opendirectory)) !== false)
{
if(($image == '.') || ($image == '..'))
{
continue;
}
$imgFileType = pathinfo($image,PATHINFO_EXTENSION);
if(($imgFileType == 'jpg') || ($imgFileType == 'png'))
{
echo "<img src='main/sub1/sub2/".$image."' width='200'> ";
}
}
closedir($opendirectory);
}
?>
Try in PHP group?
Обсуждают сегодня