[eluser]d1a8lo24[/eluser]
Yes it is an array and depending on what you are doing you can use either a $var or $var_array[].
In my code I use the $imageinfo, in the loop to be inserted in a database so for each loop and for each file there will be a database insert.
Remember this has to be done in the loop.
As for $var_array[] you wait until you finish the loop and then in order to do anything with the info you will have to loop again after the file upload loop and before returning anything or you may want to return that info.
I know everyone has their own way of coding, I have use my code in applications and as long as you know whats going on in the loop you shouldn't have a problem, you can use either my code or what toopay said just remember when to use it.
my code again with a database insert and you can do as many as you want do 3 table inserts to manage my photo app
Code:
// Do your configuration
$config['upload_path'] = $this->portfolio_path.$row->profile_account.'/';
$config['allowed_types'] = 'jpg|jpeg|gif';
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
// This is my own way of doing it rename the keys and fields for the file names you use.
$pictures = array(
'userfile_1' => $_FILES['userfile_1'],
'userfile_2' => $_FILES['userfile_2'],
'userfile_3' => $_FILES['userfile_3'],
'userfile_4' => $_FILES['userfile_4'],
'userfile_5' => $_FILES['userfile_5'],
'userfile_6' => $_FILES['userfile_6'],
'userfile_7' => $_FILES['userfile_7'],
'userfile_8' => $_FILES['userfile_8']
);
// You don't need to use these.
$i = 0;
$e = 0;
foreach($pictures as $field => $picture)
{
// If a file was not submitted do not proccess
if($picture['error'] == 0)
{
// If there is an error start image counter
if( ! $this->upload->do_upload($field) )
{
$i++;
}
// Use this to get the new image info if you need to insert it in a database
$imageinfo = $this->upload->data();
// Database insert
$data = array(
'image_name' => $imageinfo['file_name'],
'image_created_on' => now(),
'image_updated_on' => now()
);
$this->db
->insert('your_image_table', $data);
// If you insert more info another table you can use this to reference the last insert
// id and the after you will do another database insert.
$image_id = $this->db->insert_id();
} else {
$e++;
}
}
Anyway make sure how arrays and loops work otherwise you will not like the results.