Monday, May 07, 2012

Codeigniter: multifile_array upload helper

If you need to use multiple files for upload in a form, but using array names (like files[]) with Codeigniter is not possible. Besides, $_FILES schema is not compatible with $this->upload->do_upload().
With this helper you can use this kind of names for make it possible. Only use array name for all files in a form and use the helper:

In view
<input type="file" name="f_file[]">
<input type="file" name="f_file[]">

In controller
foreach ($_FILES as $file => $file_data)

Download multifile_array upload helper


hanandika said...

its worked...
thanks a lot...

chad said...

getting error :

Severity: Notice

Message: Undefined index: f_file

Filename: helpers/upload_helper.php

Line Number: 25


A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: helpers/upload_helper.php

Line Number: 28

Cristian Riffo Huez said...

Hi Chad.

Try naming your file inputs: f_file[].