I'm facing a problem.
I have actually this code:
// Check if image exist for the hotel
$src = '../assets/app/images/hotel-logos/007.jpg';
if(file_exists($src)) {
$src = $src;
}
else {
$src = '../assets/app/images/hotel-logos/default.jpg';
}
echo '<center><img src="'.$src.'" width="200"></center>';
This code check for an image existence.
But each time I have the fallback image default.jpg whereas I should have 007.jpg.
I check my path and it works. My 007.jpg image is into the same directory as my default.jpg image.
I already test with if(@getimagesize($src)) { ... }. The same.
Why ?
@) which suppresses errors. Instead test the file exists first. Why does this do$src=$src? Checkif (!file_exists(...))$src = $src;doesn't make sense.$src = $src;... really?__dir__ . '/../path/to/image.jpg. Are you sure your are pointing to the right path ?file_exists()use local path, but image's src use "URL" path... not the same.