so i have this function in my controller, but i don't know how to implement it in my view, i manage to upload the image into the database but the image that i upload didnt show up in any folder only in database and also i want to rename the image into the date:month:year(timestamp), what do i miss?
Controller
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '500';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('foto'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
$file = $data['upload_data']['full_path'];
}
}
View
<div class="form-group">
<label>Foto</label>
<input type="file" action="<?php echo site_url('admin/barang/do_upload');?>" name="foto" id="foto" class="form-control">
</div>
<button type="submit" class="btn btn-primary" style="width:100%;">Tambah</button>
EDIT
so i've been dying to do this stuff, do some research and read a lot of articles but none seems work, as far as i get my view was under form action="admin/barang/insert"
, and that makes my 2nd form get ignore, in any way how do we call 2 action in the same form?