I'm working on Wordpress at the moment and as simple as it's sounds i'm trying to check if the image is there in the directory if not then it will show a standard no-image.
My problem is that the file_exists
is returning false although the url is correct inside it, and it's accessible via browser so it's not a permission issue, and maybe i'm doing it wrong, here's the code;
$img = 'no_img.jpg';
if($val->has_prop('user_image')){
$img_tmp = $val->get( 'user_image' );
if(file_exists($upload_dir['baseurl'].'/users/'.$img_tmp)){
$img = $val->get( 'user_image' );
}
}
if i do var_dump($upload_dir['baseurl'].'/users/'.$img_tmp);
it will show the exact direct URL to the file, and it's correct one, but when it enters the file_exists
it returns $img = 'no_img.jpg'
although the file exists in the directory.... What am i doing wrong??
I tried also to add clearstatcache();
before the file_exists
but didn't work also.
Any ideas?