lin3615
// 单个文件请手册,这里多个文件中,参数设置可参考手册
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; } ?>

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
猜你喜欢
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2022-01-10
相关资源
相似解决方案