Domanda

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?

È stato utile?

Soluzione

try this

 foreach($pictures as $picture){
        if(file_exists($picture)){
           echo '<img src="'.$picture.'" />';
        }
        else{
            echo "can't read the picure";
        }
    }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top