php - File exists issues -


i'm attempting try , debug following code file_exists function. i've ran var_dump on avatar directory , returns bool(false). i'm not sure why. tested code below , gets file exists proves if statement false everytime. thoughts? have looked , image in 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; } 

$default_avatar = 'default.jpg'; $avatar_directory = 'assets/globals/images/avatars/'; if (!is_null($user_data->avatar)) {     $avatar = $avatar_directory . $user_data->avatar;     if (file_exists(fcpath . $avatar))     {         $user_data->avatar = base_url() . $avatar_directory . $user_data->avatar;     }     else     {         $user_data->avatar = base_url() . $avatar_directory . $default_avatar;     } } else {     $user_data->avatar = $default_avatar; } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -