I am using codeigniter, I want to show a user page with his profile picture shown. When a user uploads a profile picture, it will get the same name as the username (where the old profile picture will be overwritten). If he hasn't uploaded a profile picture, then a questionmark picture is shown. I use file_exists function, but it returns every time false.
$filename = base_url().'images/userimg/'.$this->session->userdata('username');
if(file_exists($filename)){
echo '<img src="'.$filename.'" width="300" height="300" /><br/>';
}
else {
echo '<img src="'.base_url().'images/no_image.jpg" width="300" height="300" /><br/>';
}