使用Codeigniter将文件添加到数据库时出错

时间:2015-05-25 14:52:40

标签: php html5 codeigniter

这个

  

致命错误:在第68行的C:\ xampp .... \ system \ helpers \ URL_helper.php中调用数组上的成员函数base_URL()

每当我使用codeigniter

将文件上传到数据库时,

总会出现

这是我的控制者:

   //for Upload
    public function Resources_Create(){
        $this->load->model("resources_section");
        if(empty($this->session->userdata("Logged_status"))){
            redirect(base_url("Admin"));
        }else{
            $this->load->helper('url');
            //$this->load->model("resources_section");
            $data['info'] = $this->admin->get_All($this->session->userdata("Logged_encryp"),$this->session->userdata("Logged_User"));
        //print_r($this->session->all_userdata());
        if($this->input->post()){
            $this->config =  array(
              'file_name'       => uniqid(rand()),
              'upload_path'     => dirname($_SERVER["SCRIPT_FILENAME"])."/assets/images/books/",
              'upload_url'      => base_url()."assets/images/books/",
              'allowed_types'   => "gif|jpg|png|jpeg",
              'overwrite'       => TRUE,
              'max_size'        => "5000KB",
              'encrypt_name'    => TRUE
            );
            $this->load->library('upload', $this->config);
            if($this->upload->do_upload())
            {
                $Image = $this->upload->data();
                $Title = filter_var($this->input->post("Title",true),FILTER_SANITIZE_STRING);
                $Author =  filter_var($this->input->post("Author",true),FILTER_SANITIZE_STRING);
                $Body = $this->input->post("Body");
                $Status = filter_var($this->input->post("Status",true),FILTER_SANITIZE_STRING);
                if($Image==null){
                    $CoverPhoto = $Image['alt.jpg'];
                }
                else{
                    $CoverPhoto = $Image['file_name'];  
                }
                $Resources = array(
                    "Book_Title"        => $Title,
                    "Book_Author"       => $Author,
                    "Book_Description"  => $Body,
                    "Status"            => $Status,
                    "Book_Image"        => $CoverPhoto 
                );
                $this->resources_section->Create_Resources($Resources);
                    if($this->input->post("Title",TRUE) != NULL){
                    //$this->news_and_events->Create($ToDatabase);
                    $data['Success'] = "<div class='alert alert-success'>Successfully Added Books & Resources!</div>";
                    redirect(base_url("Admin/Resources"));
                }
            }
            else
            {
              // print_r($this->upload->display_errors());
               $data['Success'] = "<div class='alert alert-warning'>Something Went Wrong, Please Contact The System Admin!</div>";
               redirect(base_url("Admin/Resources"));
            }
            //$this->session->set_flashdata('Status', $data['Status']);
            redirect(base_url("Admin/Resources"));
        }
        redirect(base_url("Admin/Resources"));

    }
}

我是Codeigniter的新手所以有人可以帮助我吗?

0 个答案:

没有答案