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
<form...
<input type="file" name="f_file[]">
<input type="file" name="f_file[]">
...
</form>

In controller
$this->load->helper('upload');
multifile_array();
foreach ($_FILES as $file => $file_data)
  $this->upload->do_upload($file);

Download multifile_array upload helper

4 comments:

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[].

ohanzezahl said...

Caesars Casino & Resort reopens lighter than usual
Harrah's 시흥 출장안마 Las Vegas will reopen lighter, with 진주 출장마사지 a lighter, lighter, and 구미 출장안마 lighter feel in place. Caesars 보령 출장마사지 Entertainment. The 전라북도 출장마사지 resort reopened in