I am working on my CodeIgniter project, and it is so far working very well.
However, I need some way to count the number of uploaded files, since I want to limit it in some cases (but not all).
How can I do that? I tried count($_FILES)
but that gave me nothing usable.
I also tried a bunch of other things, but neither gave me the information I need.
The upload form is a multiple file upload, and I am using this library to handle multiple uploads.
The upload function without the counting looks like this:
function do_upload()
{
$setid = $this->input->post('imageset');
$this->load->library('upload');
$this->load->library('image_lib');
$this->upload->initialize(array(
"upload_path" => "./photos/",
"allowed_types" => "jpg|jpeg|png|gif",
"encrypt_name" => TRUE
));
try {
$this->upload->do_multi_upload("files");
$images = $this->upload->get_multi_upload_data();
$config = array(
'image_library' => 'gd2',
'create_thumb' => TRUE,
'maintain_ratio' => TRUE,
'width' => '145',
'height' => '145'
);
foreach ($images as $image)
{
$config['source_image'] = $image['full_path'];
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->manage_model->insertimage($image['file_name'],$image['orig_name'],$image['file_size'],$image['file_type'],$setid);
}
$this->session->set_flashdata('success','Billederne er nu blevet uploadet.');
} catch (Exception $e) {
$this->session->set_flashdata('error', $e);
}
redirect('manage/images','refresh');
}
Any help is very appreciated.