CodeIgniter Forums
Uploading multiple images from posted array - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Uploading multiple images from posted array (/showthread.php?tid=50492)



Uploading multiple images from posted array - El Forum - 03-28-2012

[eluser]Wonder Woman[/eluser]
Hi,

I want to loop through an array to upload images but I can't seem to access the array in my controller...how can i do it so I loop the script to upload...thanks in advance.

view:
Code:
<input type="file" name="userfile[]" id="userfile" class="multi" />

controller:
Code:
$config['upload_path'] = $this->config->item('upload_path');
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$this->load->library('upload', $config);
$this->upload->initialize($config);
  
if(!$this->upload->do_upload()) {
   $data['upload_error'] = array('error' => $this->upload->display_errors());
} else {
   $data['upload_success'] = array('upload_data' => $this->upload->data());
   $this->upload_model->upload_gallery($this->upload->file_name);
}



Uploading multiple images from posted array - El Forum - 03-28-2012

[eluser]ludo31[/eluser]
Hi ;

try to adapt your code :

view :

http://pastie.org/3679320

controller :

http://pastie.org/3679335

and view success

http://pastie.org/3679342

don't forget to make lib->clear and $this->image_lib->initialize($config);