0
Codeigniter HMVC에서이 문제가 발생합니다.Codeigniter HMVC - 함수에서 라이브러리를로드 할 수 없습니다.
'업로드'또는 'image_lib'와 같은 라이브러리를로드하려면 클래스의 로컬 함수에로드하면 인스턴스가 항상 null입니다. 그러나 생성자에서 객체를 인스턴스화하면로드가 성공적으로 완료되고 라이브러리 클래스의 함수를 호출 할 수 있습니다. 누군가가이 문제를 도울 수 있다면
<?php
class Listed_items extends MX_Controller {
function __construct() {
parent::__construct();
$this->load->library('form_validation');
$this->load->library('upload'); // this works
$this->load->library('image_lib'); // this works
$this->form_validation->set_ci($this);
}
function do_upload($item_url) {
$submit = $this->input->post('submit', true);
if ($submit == "cancel") {
redirect('listed_items/create_item/'.$item_url);
} else if ($submit == "upload") {
$config['upload_path'] = './big_pics/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 300;
$config['max_width'] = 3036;
$config['max_height'] = 1902;
$file_name = $this->site_security->generate_random_string(16);
$config['file_name'] = $file_name;
$this->load->library('upload', $config); // this calls on null
}
}
}
그것은 굉장 할 것이다 :
여기에 코드입니다.