This is my code, my photo can't be inserted into the database. I don't know where the problem is.
Controller:
public function add_gambar()
{
$config['upload_path'] = './assets/img/';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '2000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( !$this->upload->do_upload('gambar'))
{
$this->Gambarhome_model->tambah_gambar_error();
redirect('gambarhome/','refresh');
}
else
{
$this->Gambarhome_model->tambah_gambar();
redirect('gambarhome/','refresh');
}
}
Model:
function tambah_gambar(){
$date = $this->upload->data();
$data=array(
'judul'=>$this->input->post('judul'),
'desc'=>$this->input->post('desc'),
'gambar'=>$date['file_name']
);
$this->db->insert('gambarhome',$data);
}
Someone help me pls, thank you!