您好我是新代码点火器。我的问题是当我在项目创建期间尝试上传图像时,我收到以下错误。
“遇到PHP错误
严重性:注意
消息:未定义属性:Home :: $ upload
文件名:controllers / home.php
行号:68
致命错误:在第68行的application / controllers / home.php中调用非对象的成员函数initialize()“
我的代码是
class Home extends CI_Controller
{
public function index()
{
$this->load->model("content_model");
if (!$this->user->loggedin) {
$projects = $this->content_model->get_projects();
} else {
$projects = $this->content_model
->get_user_projects($this->user->info->ID);
}
$icons = $this->content_model->get_icons();
$this->template->loadContent("home/index.php", array(
"icons" => $icons,
"projects" => $projects
)
);
}
,出现第68行的错误就是这个,
$image = "";
if ($_FILES['userfile']['size'] > 0
&& $this->settings->info->project_upload_icon) {
$this->upload->initialize(array(
"upload_path" => $this->settings->info->upload_path,
"overwrite" => FALSE,
"max_filename" => 500,
"encrypt_name" => TRUE,
"remove_spaces" => TRUE,
"allowed_types" => "gif|jpg|png|jpeg",
"max_size" => 3000,
"xss_clean" => TRUE,
"max_width" => 92,
"max_height" => 92
));
请帮助我解决这个问题
答案 0 :(得分:1)
您需要在autoload.php页面或相应的控制器页面中加载“上传”库,以便它可以识别上传对象。 在autoload.php中,您只需要在库数组中添加库的名称。