一切都很好,但是當我打開上傳文件夾時,沒有任何圖像。代碼圖片上傳
這裏是控制器「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 />
....
我認爲你是缺少控制器/函數名稱的形式打開標籤 '??????echo form_open_multipart(''); ?> –
這不是說,beacouse以相同的形式,我有標題,新聞和類別,他們進入datebase的權利:) – Ant