How to upload 2 separate images in codeigniter

sheraz iqbal picture sheraz iqbal · Apr 7, 2016 · Viewed 7.6k times · Source

i want to upload 2 image separately. i have a condition in which i need to upload file and some time bohth and some time only image i need to use separate button how to differentiate both image and file.

my codes are

<form action="http://localhost/cod_login/club/test2" enctype="multipart/form-data" method="post" accept-charset="utf-8">
  <input type="file" name="userfile" size="20">
  <input type="file" name="userfile" size="20">
  <input type="submit" name="submit" value="upload">
</form>

this is controller

function ddoo_upload(){
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '100';
    $config['max_width']  = '1024';
    $config['max_height']  = '768';

    $this->load->library('upload', $config);

    if ( ! $this->upload->do_upload()) {
        $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);
    }
}

Answer

Hanan Ashraf picture Hanan Ashraf · Apr 7, 2016
<form action="http://localhost/cod_login/club/test2" enctype="multipart/form-data" method="post" accept-charset="utf-8">


<input type="file" name="userfile" size="20" multiple="">
<input type="submit" name="submit" value="upload">
</form>