Question

I have pictures readed in foreach loop. I need to check if picture can be readed from folder and show it. If picture is not in folder or can't be readed have to print some message. So in followng code:

foreach($pictures as $picture){
if(is on disk in proper folder and can be readed properly){
    echo HTML::image($picture);
}
else{
    echo "can't read the picure";
}

}

how to check if picture is on disk in proper folder and can be readed properly?

Was it helpful?

Solution

try this

 foreach($pictures as $picture){
        if(file_exists($picture)){
           echo '<img src="'.$picture.'" />';
        }
        else{
            echo "can't read the picure";
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top