File exists issues
I'm attempting to try and debug the following code with the file_exists
function. I've ran a var_dump on the avatar directory and it always
returns as bool(false). I'm not sure why. I tested the code below and it
gets to the file exists but it proves the if statement false everytime.
Any thoughts? I have looked and the image is in the directory correctly.
$default_avatar = 'default.jpg';
$avatar_directory = base_url() . 'assets/globals/images/avatars/';
if (!is_null($user_data->avatar))
{
$avatar = $avatar_directory . $user_data->avatar;
if (file_exists($avatar))
{
$user_data->avatar = $avatar_directory . $user_data->avatar;
}
else
{
$user_data->avatar = $avatar_directory . $default_avatar;
}
}
else
{
$user_data->avatar = $default_avatar;
}
No comments:
Post a Comment