// 单个文件请手册,这里多个文件中,参数设置可参考手册
view 视图
<form...>
<input type="file" name="userfile[]">
<input type="file" name="userfile[]">
...
</form>
controller 控制器
<?php
$config[\'upload_path\'] = \'./uploads/\';
$config[\'allowed_types\'] = \'gif|gpg|gpeg|png\';
$config[\'max_size\'] = \'2000\';
$config[\'max_width\'] = \'1024\';
$config[\'max_height\'] = \'1000\';
$this->load->library(\'upload\', $config);
// 函数用来分析数组
multifile_array();
foreach ($_FILES as $file => $file_data)
{
$this->upload->do_upload($file);
// 返回的信息,可入数据库
$data[] = array(\'upload_data\' => $this->upload->data());
}
// multifile_array()函数
function multifile_array()
{
if(count($_FILES) == 0)
return;
$files = array();
$all_files = $_FILES[\'userfile\'][\'name\'];
$i = 0;
foreach ($all_files as $filename) {
$files[++$i][\'name\'] = $filename;
$files[$i][\'type\'] = current($_FILES[\'userfile\'][\'type\']);
next($_FILES[\'userfile\'][\'type\']);
$files[$i][\'tmp_name\'] = current($_FILES[\'userfile\'][\'tmp_name\']);
next($_FILES[\'userfile\'][\'tmp_name\']);
$files[$i][\'error\'] = current($_FILES[\'userfile\'][\'error\']);
next($_FILES[\'userfile\'][\'error\']);
$files[$i][\'size\'] = current($_FILES[\'userfile\'][\'size\']);
next($_FILES[\'userfile\'][\'size\']);
}
$_FILES = $files;
}
?>