Hi Guys,
Basing from
http://www.codeigniter.com/userguide3/li...ading.html I'm trying to implement method ('process_upload'), that would upload multiple files. the idea is basically from the tutorial, only i added some loop just in case of multiple input.
PHP Code:
public function process_upload( $input_field_name, $config = array() ) {
for ($key = 0; $key < count($_FILES[$input_field_name]['name']); $key++) {
$_FILES[$input_field_name]['name'] = $_FILES[$input_field_name]['name'][$key];
$_FILES[$input_field_name]['type'] = $_FILES[$input_field_name]['type'][$key];
$_FILES[$input_field_name]['tmp_name'] = $_FILES[$input_field_name]['tmp_name'][$key];
$_FILES[$input_field_name]['error'] = $_FILES[$input_field_name]['error'][$key];
$_FILES[$input_field_name]['size'] = $_FILES[$input_field_name]['size'][$key];
$this->load->library('upload', $config);
if ( !$this->upload->do_upload($input_field_name) ) {
return array('upload_error' => $this->upload->display_errors());
} else {
return array('upload_data' => $this->upload->data());
}
}
}
Then call the method ('process_upload') in other method ('set_upload') like:
PHP Code:
public function set_upload() {
// Config your upload settings
$config['upload_path'] = './public/images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$field = 'myfile'; // Input File field
$data = $this->process_upload($field, $config);
}
Now, if i try to upload 3 files, only 1 file is uploaded to its upload path directory. Cany anyone please help, how can i resolved this issue.
Thanks, in advanced.