CodeIgniter Forums
How to upload files with multiple incremented/numbered fields? - 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: How to upload files with multiple incremented/numbered fields? (/showthread.php?tid=46053)



How to upload files with multiple incremented/numbered fields? - El Forum - 10-16-2011

[eluser]Ludovic-r[/eluser]
I want to upload files with CodeIgniter through generated numbered upload fields :

Code:
<input type='file' name='field[0]' />
<input type='file' name='field[1]' />

These upload fields are among another inputs fields :

Code:
<input type='file' name='field[0]' />
<input type='TEXT' name='field[1]' />
<input type='file' name='field[2]' />

I just want to upload the files when the user click on the Submit button and keep this specific inputs structure

I've tried this but it doesn't work :

Code:
for($i=0; $i<count($_FILES); $i++)
     {

       $config['upload_path']   = './uploads/';
       $config['allowed_types'] = 'jpg|jpeg|gif|png';
       $config['overwrite']     = FALSE;

      $this->upload->initialize($config);
$this->upload->do_upload('field['.$i.']');


     }

Any help would be very appreciated! Thanks!