I’m wondering whats wrong with my code why it is throwing me this error “Call to a member function check_if_image_exist() on a non-object D:\xampp\htdocs\project-001\application\controllers\c_userHome.php on line 48”
I have the same code with my other functions but the others works fine.. Im smashing my head with this error 🙁
This is in my controller:
//check if dir has image
$this->load->library('image_checker');
$this->image_checker->check_if_image_exist(); //this is line 48
This is in my library which i call:
class Image_checker extends CI_Controller {
var $userfile_path;
function __construct()
{
parent::__construct();
$this->userfile_path = realpath(APPPATH . '../userfiles/');
}
public function check_if_image_exist()
{
$user = $this->session->userdata('username');
$dir = $this->userfile_path;
$handle = opendir($dir);
while(($file = readdir($handle)) !== false){
if($file != "." && $file != ".."){
$file_list[] = $file;
}
}
closedir($handle);
return $file_list;
}
}
Thanks in Advance!
-Darryl
that seems to be your controller, since you are extending
CI_Controller,so change:
to
See more: Codeigniter Custom Libraries