php - multiple image upload codeigniter with different input tag -


i have following codeigniter code depends on number of directors. means if nos of directors 2, following code of 2 times. used unique id. want upload images (3 images of 1 director) in single click. names should start director1_

<div class="row">                             <h5 style="padding: 0 15px;">details director 1</h5>                             <div class="form-group col-md-4">                                 <label>full name</label>                                 <input type="hidden" name="director[0][cid]" value="9">                                 <input type="text" class="form-control" name="director[0][name]" required="required" placeholder="enter full name" autocomplete="off">                             </div>                             <div class="form-group col-md-4">                                 <label>father's name</label>                                 <input type="text" class="form-control" name="director[0][fname]" required="" placeholder="enter father's name">                             </div>                             <div class="form-group col-md-4">                                 <label>address</label>                                 <input type="text" class="form-control" name="director[0][address]" placeholder="enter address">                             </div>                             </div> <div class="row">                             <div class="form-group col-md-4">                                 <label>color photograph</label>                                 <input type="file" class="form-control" name="image[0][photo]">                             </div>                             <div class="form-group col-md-4">                                 <label>pan card</label>                                 <input type="file" class="form-control" name="image[0][pan]">                             </div>                             <div class="form-group col-md-4">                                 <label>address proof</label>                                 <input type="file" class="form-control" name="image[0][address]">                             </div>                             </div> 

in controller, have used following code

function upload_files($path, $title, $files) {     $config = array(         'upload_path'   => $path,         'allowed_types' => 'jpg|gif|png',         'overwrite'     => 1,                            );      $this->load->library('upload', $config);      $images = array();      foreach ($files['image'] $key => $image) {         $_files['images[]']['name']= $files['name'][$key];         $_files['images[]']['type']= $files['type'][$key];         $_files['images[]']['tmp_name']= $files['tmp_name'][$key];         $_files['images[]']['error']= $files['error'][$key];         $_files['images[]']['size']= $files['size'][$key];          $filename = $title .'_'. $image;          $images[] = $filename;          $config['file_name'] = $filename;          $this->upload->initialize($config);          if ($this->upload->do_upload('images[]')) {             $this->upload->data();         } else {             return false;         }     }      return $images; } 

but, it's not working. appreciated


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -