Вот мой код:
*** Контроллер ***
Код: Выделить всё
function saveEvent(){
$config = [
'upload_path' => './assets/img',
'allowed_types' => 'gif|png|jpg|jppeg'
];
$this->load->library('upload', $config);
$this->form_validation->set_error_delimiters();
$this->upload->do_upload();
// var_dump('asd'. $this->upload->do_upload());
// if($this->upload->do_upload()){
$datas = $this->input->post('eventimage');
$info = $this->upload->data();
$image_path = "./assets/img/".$info['raw_name'].$info['file_ext'];
$data['cal_events_image'] = $image_path;
$data['cal_events_name'] = $this->input->post('eventname');
unset($data['submit']);
$this->load->model('CalendarModel');
if($this->CalendarModel->eventinsertdata($data)){
echo "success";
}else{
echo " fail";
}
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/55646275/how-to-upload-data-to-database-using-codeigniter[/url]