CodeIgniter Forums
Best Way to Upload Array of Files? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Best Way to Upload Array of Files? (/showthread.php?tid=43892)



Best Way to Upload Array of Files? - El Forum - 07-27-2011

[eluser]ShoeLace1291[/eluser]
I have a form that will let a user upload one or more files. The number will always be different because they will be able to add another file input by clicking on a submit button. This will add another input field called "file[]" and will output an array of files. What's the best way to upload an array of files?

PS: A feature should be added to CI that will give the ability to upload an array of files.


Best Way to Upload Array of Files? - El Forum - 07-27-2011

[eluser]Eric Barnes[/eluser]
Check out this one - https://github.com/nicdev/CodeIgniter-Multiple-File-Upload

Should do what you need.


Best Way to Upload Array of Files? - El Forum - 08-03-2011

[eluser]nuwanda[/eluser]
Isn't this a client-side question?

You can specify in html the number of files to upload using file[], so you may have:

file[]
file[]
file[]

for three file inputs.

That will be posted as 3 elements of $_POST['file'].

If you need a variable number of file inputs you'll need to have javascript add subsequent input elements on the client-side as requested.

No?