An addition to the CI_Upload, that allows for multiple files upload.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 747b703 Aug 3, 2015
Failed to load latest commit information.
controllers First commit Jan 10, 2015
libraries Update MY_Upload.php Aug 2, 2015
views First commit Jan 10, 2015 added instructions Jan 12, 2015


This library is an extension of the CI_Upload library that will allow you to upload multiple files.

How to install

Just move libraries/MY_Upload.php to your application/libraries/ directory.

How to use it:

First of all, let's make the view for uploading multiple files:

<h1>Upload multiple files</h1>
<?php echo form_open_multipart();?>
<p>Upload file(s):</p>
<?php echo form_upload('uploadedimages[]','','multiple'); ?>
<br />
<br />
<?php echo form_submit('submit','Upload');?>
<?php echo form_close();?>

Now, in controller, if a form was submited, we set the configuration and load the library:

$config = array(
	'upload_path' => './upload/',
	'allowed_types' => 'jpg|gif',
	'max_size' => '2048',
	'multi' => 'all'

// load Upload library

As you can see, the $config array has a new key: "multi". This key can accept one of three values:

  • 'all' = only upload if all files are uploaded
  • 'halt' = halt uploading after first encountered error
  • 'ignore' = ignore errors and continue uploading remaining files

Once we've loaded the library, we can simply call do_upload() on our input element:


Take care here: $this->upload->do_upload() returns FALSE only if an error was encountered AND:

  • either the user tried to upload only one file;
  • or the user tried to load more than one file BUT the $config['multi'] was set to 'all'.

After the upload, we can retrieve the data of the uploaded files with $this->upload->data():

echo '<pre>';
$uploaded = $this->upload->data();
echo '</pre>';

Also, in case of upload errors, we can retrieve the errors with $this->upload->display_errors:

echo '<pre>';
echo '</pre>';