Dan berikut code controllernya:
function do_upload() { $this->load->library('upload'); //config untuk upload gambar $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'jpg|png'; $config['overwrite'] = FALSE; $config['max_size'] = '5000'; $this->upload->initialize($config); if (!$this->upload->do_upload('gambar')) { /* * LOAD HALAMAN ERROR GAMBAR */ } else { unset($config); $config['upload_path'] = './uploads/'; $config['upload_path'] = './assets/download/news/'; $config['allowed_types'] = 'pdf'; $config['overwrite'] = FALSE; $config['max_size'] = '15000'; $this->upload->initialize($config); if (!$this->upload->do_upload('file_download')) { /* * LOAD HALAMAN ERROR FILE PDF */ } else { /* * LOAD HALAMAN SUKSES */ } } }
dengan menambahkan $this->upload->initialize($config); kita dapat setting configurasi untuk file upload selanjutnya.