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?

有帮助吗?

解决方案

try this

 foreach($pictures as $picture){
        if(file_exists($picture)){
           echo '<img src="'.$picture.'" />';
        }
        else{
            echo "can't read the picure";
        }
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top