In my CodeIgniter project I\'m uploading files during the project creation. Here\'s the uploading function:
function uploadFiles(){
$this->load->
This is an extension of the CI_Upload class that I modified to upload multiple files, just copy this to the MY_Upload.php file. It also makes the directory as well.
http://pastebin.com/g9J6RxW1
Then all you need to do in the controller function is arrange your files into the an array, where the name of the field and the key are the array keys and the config is the data. In you case something like this:
$project_files['files'][0] = array(
'upload_path' => './uploads/'.$projectName.'/',
'max_size' => 0,
'allowed_types' => 'xml|etl',
'overwrite' => TRUE,
'remove_spaces' => TRUE,
);
$project_files['files'][1] = array(
'upload_path' => './uploads/'.$projectName.'/',
'max_size' => 0,
'allowed_types' => 'xml|etl',
'overwrite' => TRUE,
'remove_spaces' => TRUE,
);
IF all the files configs are the same just make a for loop to set this up, it will also take 'named keys', ie. $project_files['files']['file_key']
.
then just call:
if($this->upload->upload_files($project_files)){/*all files uploaded successfully*/}