Aug 14

Upload Multiple Files in Code Igniter

Code Igniter's Upload library is great, but doesn't allow you to upload multiple files. If you want to use the library, but need to do multiple file uploads, replace your /libraries/Upload.php file with this:
Upload.php

And here's how to do multiple uploads from your controller:

foreach ($_FILES["photo"]["error"] as $key => $error)
{								
	if($this->upload->do_upload("photo[$key]"))
	{
		$upload = $this->upload->data();
		
		// do stuff with your upload data here...
	}
	else
	{
		$data['upload_errors'] = $this->upload->display_errors('

', '

'); } }

Note: This will not affect your ability to do single uploads like you normally could.