我有一個頁面的表單。表單上有一個下拉列表和一些輸入框和一個文件上傳。如果我嘗試提交我的頁面,則會出現一個空白頁面,並顯示錯誤「不存在的類:上傳」。我還沒有使用文件上傳。codeigniter文件上傳與其他元素
這是我的輸入文件類型:
<tr><td>Image: </td></tr>
<tr><td><input type="file" name="image" size="20" /></td></tr>
我的,你需要一個form_open_multipart(「上傳」)的CI文件上傳類閱讀;那麼,我只是有這種形式,還是必須在我的情況下做其他事情?因爲我在該表單上有其他輸入類型?
這裏是我的控制器的一點點代碼:
$subject = htmlspecialchars(trim($this->input->post('subject')));
$message = htmlspecialchars(trim($this->input->post('message')));
$image = $this->input->post('image');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload($image)) {
$data['fout'] = $this->upload->display_errors();
$this->annuleren($soort, $data);
} else {
$data['upload'] = $this->upload->data();
}
$id = $this->message_model->insert($message, $subject, $image);
redirect('infoscreen/dashboard', 'refresh');
我也做了一個文件夾「上傳」下「源文件」。我可能在做一些愚蠢的事情。有人可以幫助我,並告訴我我做錯了什麼,我該如何解決它?
非常感謝:)
噢好吧,但我仍然有這個錯誤。你把userfile添加到do_upload意味着什麼? – Lewis
啊,是的,你需要'$ this-> load-> library('upload');'看看我的編輯。 – jtheman
即使我註釋掉 - > do_upload代碼等,它仍然會給出相同的錯誤。 – Lewis