문제

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