//处理文件上传数据
public functiondo_upload(){
//重新组合一个$_FILES中的格式 使其变为和上传单个文件的数据格式类似
foreach($_FILES['myfile'] as $index => $vals){
foreach ($vals as $i => $val) {
$file_map[$i]['myfile'][$index] = $val;
}
}
foreach ($file_map as $files) {
$config['upload_path'] = './uploads/admin/test';
$config['file_name'] = uniqid();
$config['allowed_types'] = 'gif|jpg';
//遍历 这样每次都去覆盖掉$_FILES中的数据 (PS:这样覆盖后,$_FILES格式就和上传单个文件的格式是一模一样的了)
$_FILES = $files;
$this->load->library('upload',$config);
$this->upload->do_upload("myfile");
echo $this->upload->display_errors();
var_dump($this->upload->data());
}
}
就是这样的。才可以解决 CIyang 发表于 2016-5-6 16:11
**** 作者被禁止或删除 内容自动屏蔽 ****
如何存储到数据库中? foreach($_FILES as $key=>$val)
{
$filename = $val['name'];
}
echo "<pre>";
var_dump($filename);
echo "</pre>";
die;
打印结果string(7) "789.jpg",上传两张只有一个图片的名字,是我哪里写错了吗,
页:
1
[2]