我在嘗試使用上傳庫時,很難確定我在做什麼錯誤/如何解決它。我有一個包含多個字段(主要是文本)的表單,其中包含一個圖片上傳字段。輸入到文本字段中的數據已正確填充到我的數據庫中,但是用戶瀏覽到要上載的圖像文件沒有顯示在我創建的根目錄中,其權限允許將其寫入。所有的幫助非常感謝。謝謝!CI:圖片上傳到文件夾不起作用
下面局部視圖:
<p>
<label for="uEventFillByDateTime">Event Fill-by Date/Time:</label>
<input type="text" id="uEventFillByDateTime" name="uEventFillByDateTime" />
</p>
<p>
<label for="uEventImage">Event Image:</label>
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="uEventImage" size="20" id="uEventImage" />
</p>
<p>
<label for="uEventKeywords">Event Keywords:</label>
<textarea id="uEventKeywords" name="uEventKeywords"></textarea>
</p>
控制器電話:
public function createEvent() {
if(!empty($_POST)) {
echo $this->event_model->createEvent();
}
}
型號代碼:
public function createEvent() {
$this->image_path = realpath(APPPATH . 'event_images');
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->image_path,
'max_size' => 2000,
'max_width' => 212,
'max_height' => 118
);
$this->load->library('upload', $config);
$this->upload->do_upload();
$image_data = $this->upload->data();
/*format date time from string to mysql */
$cdt = $this->input->post('cEventDateTime', true);
$cdtMySQL = date("Y-m-d H:i:s", strtotime($cdt));
/*format fill-by date time from string to mysql */
$cfdt = $this->input->post('cEventFillByDateTime', true);
$cfdtMySQL = date("Y-m-d H:i:s", strtotime($cfdt));
$data = array(
'event_name' => $this->input->post('cEventName', true),
'event_datetime' => $cdtMySQL,
'event_fillbydatetime' => $cfdtMySQL,
'event_keywords' => $this->input->post('cEventKeywords', true),
'event_notes' => $this->input->post('cEventNotes', true),
'event_featured' => $this->input->post('cEventFeatured', true),
'fk_venue_id' => $this->input->post('cEventVenue', true),
'fk_eventtype_id' => $this->input->post('cEventType', true),
'fk_eventlifecycle_id' => $this->input->post('cEventlifecycle', true),
);
$this->db->insert('event', $data);
return $this->db->insert_id();
}