例子一:
rush:PHP;">
/**
* 多文件上传
*
* @author Dream
*/
public function multiple_uploads() {
//载入所需类库
$this->load->library('upload');
//配置上传参数
$upload_config = array(
'upload_path' => '','allowed_types' => 'jpg|png|gif','max_size' => '500','max_width' => '1024','max_height' => '768',);
$this->upload->initialize($upload_config);
//循环处理上传文件
foreach ($_FILES as $key => $value) {
if (!empty($key['name'])) {
if ($this->upload->do_upload($key)) {
//上传成功
print_r($this->upload->data());
} else {
//上传失败
echo $this->upload->display_errors();
}
}
}
}
例子二:
$config['file_name'] = time(); //文件名不使用原始名
$this->load->library('upload',$con<a href="https://www.jb51.cc/tag/fig/" target="_blank" class="keywords">fig</a>);
if(!$this->upload->do_upload()) {
echo $this->upload-><a href="https://www.jb51.cc/tag/dis/" target="_blank" class="keywords">dis</a>play_errors();
}else{
$data['upload_data']=$this->upload->data(); //<a href="https://www.jb51.cc/tag/wenjian/" target="_blank" class="keywords">文件</a>的一些信息
$img=$data['upload_data']['file_name']; //取得<a href="https://www.jb51.cc/tag/wenjian/" target="_blank" class="keywords">文件</a>名
echo $img."<br>";
foreach($data['upload_data'] as $item => $value){
echo $item.":".$value."<br>";
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。