Frage

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?

War es hilfreich?

Lösung

try this

 foreach($pictures as $picture){
        if(file_exists($picture)){
           echo '<img src="'.$picture.'" />';
        }
        else{
            echo "can't read the picure";
        }
    }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top