모든 것이 정상이지만 업로드 폴더를 열면 이미지가 없습니다.사진이 codeigniter에 업로드되었습니다.
여기에 컨트롤러 "admin_news"가 있습니다. localhost/site/asset/upload에 이미지 파일을 업로드하려고합니다. 그러나 제출을 클릭하면 정보 (제목, 뉴스 및 카테고리) 만 데이터베이스에 저장되지만 파일은 업로드되지 않습니다.
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'html', 'file'));
$config['upload_path'] = base_url('asset/upload/');
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
}
public function add_news(){
$this->load->helper('form');
$this->load->model('AddNews');
$this->load->view('templates/header', $data);
$this->load->view('admin/add_news');
$this->load->view('templates/footer');
if($this->input->post('submit')){
if ($this->upload->do_upload('image'))
{
$this->upload->initialize($config);
$this->upload->data();
}
$this->AddNews->entry_insert();
redirect("admin_news/index");
}
}
뷰에만 있습니다
<?php echo form_open_multipart(''); ?>
<input type="text" name="title" value="Title..." onfocus="this.value=''" /><br />
<input type="file" name="image" /><br />
....
나는 컨트롤러/함수 이름이 열린 태그 형태로 없다고 생각한다. ' php echo form_open_multipart (''); ?>' –
그것은 동일한 형태의 비 코즈가 아닙니다. 제목, 뉴스 및 카테고리가 datebase 오른쪽으로 들어갑니다. – Ant