[eluser]1mr3yn[/eluser]
Good Day Developers,
Im currently developing a website that allowed a user to upload 1 image as his/her profile picture.
The Uploading stuff is ok, using 'File Uploading Class'.
Code:
$config = array (
'file_name' => $this->input->post('user_id'),
'upload_path' => './img/members',
'allowed_types' => 'gif|jpg|png',
'max_size' => '100',
'max_width' => '1024',
'max_height' => '768',
'overwrite' => TRUE,
);
by looking at the code, it's too obvious that that i did not store the image name in the database, instead renaming it, that is the same with the user_id of a specific user. And it works fine. But my problem is read and display that user image in his/her profile page.
I have a function the looks like this:
Code:
function getProfilePhoto($id)
{
$image = img_url().'members/'.$id.".jpg";
if ( !file_exists($image)){
$swap = img_url().'members/selena.jpg';
return "<img src="$image" />";
}
else {
return "<img src="$image" />";
}
}
my problem is my 'file_exists' seems won't work and since im using
Quote:'allowed_types' => 'gif|jpg|png',
how will i know if that image is gif,png or jpg?
Thanks guys.