<pre name="code" class="php">//multiple="multiple" 并将name 改为数组[];
<form action="<?php echo site_url(MODULE. '/'. C. '/'. M) ?>" method="post" enctype="multipart/form-data" class="jqtransform"></span>
<table>
<tr>
<td valign="top" class="td_right">图片:</td>
<td>
<input type="text" name="image" class="input-text lh30">
<input type="file" name="file_field[]" multiple="multiple">
</td>
</tr>
</table>
</form>
//拿到$_FILES数组 并把数组重新排列;
$files = array();
if ( ! empty($_FILES)) {
$fileLen = count($_FILES["file_field"]["name"]);
for ($i=0; $i<$fileLen; $i++) {
$files[] = array(
"name" => $_FILES["file_field"]["name"][$i],
"type" => $_FILES["file_field"]["type"][$i],
"tmp_name" => $_FILES["file_field"]["tmp_name"][$i],
"error" => $_FILES["file_field"]["error"][$i],
"size" => $_FILES["file_field"]["size"][$i]
);
}
}
//循环上传文件
foreach($files as $file => $value) {
$_FILES[$name] = $value;
if ( ! $this->upload->do_upload('file_field'))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
return FALSE;
}
else
{
$data = $this->upload->data();
//return $config['upload_path']. $data['file_name'];
}
}
参考