首页 > 其他 > 详细

ci 多个文件同时上传

时间:2014-07-02 18:20:50      阅读:382      评论:0      收藏:0      [点我收藏+]
// 单个文件请手册,这里多个文件中,参数设置可参考手册
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; } ?>

 

ci 多个文件同时上传,布布扣,bubuko.com

ci 多个文件同时上传

原文:http://www.cnblogs.com/lin3615/p/3819780.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!