码迷,mamicode.com
首页 > Web开发 > 详细

php多文件上传

时间:2016-03-08 16:23:35      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

多文件上传
<input type="file" name="file[]" multiple />


<?php function reArrayFiles(&$file_post) {   $file_ary = array();   $file_count = count($file_post[name]);   $file_keys = array_keys($file_post);   for ($i=0; $i<$file_count; $i++) {     foreach ($file_keys as $key) {       $file_ary[$i][$key] = $file_post[$key][$i];     }   }   return $file_ary; } ?> 打印 $_FILES -------- array(1) { ["file"]=> array(5) { ["name"]=> array(5) { [0]=> string(20) "06_avatar_middle.jpg" [1]=> string(44) "7e3e6709c93d70cf7086f212ffdcd100baa12bb4.jpg" [2]=> string(20) "57U58PIC47y_1024.jpg" } ["type"]=> array(5) { [0]=> string(10) "image/jpeg" [1]=> string(10) "image/jpeg" [2]=> string(10) "image/jpeg" } ["tmp_name"]=> array(5) { [0]=> string(53) "C:\Users\Administrator\AppData\Local\Temp\phpE364.tmp" [1]=> string(53) "C:\Users\Administrator\AppData\Local\Temp\phpE3D2.tmp" [2]=> string(53) "C:\Users\Administrator\AppData\Local\Temp\phpE431.tmp" } ["error"]=> array(5) { [0]=> int(0) [1]=> int(0) [2]=> int(0) } ["size"]=> array(5) { [0]=> int(202387) [1]=> int(168931) [2]=> int(116158) } } } ---------
处理 $filesArr
= reArrayFiles($_FILES[file]);
处理后
打印 $filesArr
----------- array(3) { [0]=> array(5) { ["name"]=> string(20) "06_avatar_middle.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(53) "C:\Users\Administrator\AppData\Local\Temp\php5E0E.tmp" ["error"]=> int(0) ["size"]=> int(202387) } [1]=> array(5) { ["name"]=> string(44) "7e3e6709c93d70cf7086f212ffdcd100baa12bb4.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(53) "C:\Users\Administrator\AppData\Local\Temp\php5E9B.tmp" ["error"]=> int(0) ["size"]=> int(168931) } [2]=> array(5) { ["name"]=> string(20) "57U58PIC47y_1024.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(53) "C:\Users\Administrator\AppData\Local\Temp\php5EFA.tmp" ["error"]=> int(0) ["size"]=> int(116158) } }

技术分享

php多文件上传

标签:

原文地址:http://www.cnblogs.com/qhorse/p/5254248.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!