I’m learning CodeIgniter. I have a directory img with images (path /img/). I am trying to access it through CI view and check if exists with this code:
$av = '../../../img/content/users/'.$userID.'.jpg';
if(file_exists($av)) {
$avatar = $av;
} else {
$avatar = 'img/content/users/none.jpg';
}
Funny thing is, echoing <img src="'.$av.'"> works. What should I do?
Use following steps
1) Create a custom config file name site_config.php in config file (/application/config/) and paste following code
2) Edit autoload.php to autoload site_config.php (/application/config/autoload.php)
3) Then using following code to view image
I think it will help you