技术的世界只说技术就好了..

分类目录

近期文章

标签

近期评论

功能

2018年八月
« 11月    
 12345
6789101112
13141516171819
20212223242526
2728293031  

PHP BIGQI::FilesUpload批量上传类..

php批量上传管理器 BIGQI::FilesUpload批量类应用
php批量上传管理器为 BIGQI::FilesUpload类应用演示
更多精彩请关注 http://127.0.0.1/wordpress
作者 Haierspi QQ78523116
使用方法:
上传解压包的文件到PHP执行目录
用连接访问file.php?code=20090911
后面的 20090911是验证信息..就是当前服务器的日期,为了把一些人堵在外面 (*^__^*) 嘻嘻……
验证正确就可以使用了 失败会自动跳转页面

[img]http://bbs.nc0791.cn/attachments/dvbbs/2009-7/def8b89cebd66088f1a6afe2f4bc50c4.jpg[/img]

下载:http://www.damipan.com/file/3YKoGWh.html

发布个我自己写的PHP批量上传类..

 

HTML页面部分:

XML/HTML代码
        

  1. <form enctype="multipart/form-data" method="post" name="upform">
  2.     

  3. 上传文件: br><br>
  4.     

  5. 1.<input name="upfile[]" type="file" size="30"><br><br>
  6.     

  7. 2.<input name="upfile[]" type="file" size="30"><br><br>
  8.     

  9. 3.<input name="upfile[]" type="file" size="30"><br><br>
  10.     

  11. 4.<input name="upfile[]" type="file" size="30"><br><br>
  12.     

  13. <input type="submit" value="上传" size="17">
  14.     

  15. </form>

[separator]

核心类

        

  1. class FilesUpload {
  2.     

  3. var $maxsize = 0 ;
  4.     

  5. var $src_fsizes = 0;
  6.     

  7. var $sux = array ('gif', 'jpg', 'png', 'zip', 'rar', 'txt', 'doc', 'pdf');
  8.     

  9. var $dst_path = './upload';
  10.     

  11. var $dst_name = 'randstring().\'.\'.$Files[\'type\'];';
  12.     

  13. var $errver = false;
  14.     

  15. var $errfile = 0;
  16.     

  17. var $errno = 0;
  18.     

  19. var $error = '';
  20.     

  21. var $reinfo = '';
  22.     

  23.  
  24.     

  25. function __construct(){
  26.     

  27. $this->FilesUpload();
  28.     

  29. }
  30.     

  31.  
  32.     

  33. function FilesUpload(){
  34.     

  35. $this->maxsize = (int) ini_get ( 'upload_max_filesize' ) * 1024 * 1024;
  36.     

  37. $this->dst_path = BIGQI_ROOT.$this->dst_path;
  38.     

  39. }
  40.     

  41.  
  42.     

  43. function maxsize($maxsize){
  44.     

  45. $this->maxsize = $maxsize * 1024; //kb
  46.     

  47. }
  48.     

  49.  
  50.     

  51. function send($Uploadfiles){
  52.     

  53. for($i = 0; $i < count ( $Uploadfiles ['name'] ); $i ++) {
  54.     

  55. $upload_name = $Uploadfiles ['name'] [$i];
  56.     

  57. $upload_tmpname = $this->str_fillter ( $Uploadfiles ['tmp_name'] [$i] );
  58.     

  59. $upload_size = $Uploadfiles ['size'] [$i];
  60.     

  61. $upload_mime = $Uploadfiles ['type'] [$i];
  62.     

  63. $upload_type = getfilesux ( $Uploadfiles ['name'] [$i] );
  64.     

  65. if (!$upload_name && !$upload_tmpname && !$upload_size && !$upload_mime && !$upload_type){
  66.     

  67. continue;
  68.     

  69. }
  70.     

  71.  
  72.     

  73. if ($Uploadfiles ['error'] [$i] != 0) {
  74.     

  75. $this->errver = true;
  76.     

  77. $this->errfile = $i;
  78.     

  79. $this->errno = 10;
  80.     

  81. $this->error = $Uploadfiles ['error'] [$i];
  82.     

  83. return false;
  84.     

  85. }
  86.     

  87. if (! in_array ( $upload_type, $this->sux )) {
  88.     

  89. $this->errver = true;
  90.     

  91. $this->errfile = $i;
  92.     

  93. $this->errno = 20;
  94.     

  95. $this->error = 'UploadFile type error!';
  96.     

  97. return false;
  98.     

  99. }
  100.     

  101. if (! is_uploaded_file ( $upload_tmpname )) {
  102.     

  103. $this->errver = true;
  104.     

  105. $this->errfile = $i;
  106.     

  107. $this->errno = 30;
  108.     

  109. $this->error = 'UploadFile tmpname error!';
  110.     

  111. return false;
  112.     

  113. }
  114.     

  115. if (! $upload_size ) {
  116.     

  117. continue;
  118.     

  119. }else{
  120.     

  121. $this->src_fsizes += $upload_size;
  122.     

  123. }
  124.     

  125. $DstFiles [$i] ['name'] = $upload_name;
  126.     

  127. $DstFiles [$i] ['temp'] = $upload_tmpname;
  128.     

  129. $DstFiles [$i] ['size'] = $upload_size;
  130.     

  131. $DstFiles [$i] ['type'] = $upload_type;
  132.     

  133. $DstFiles [$i] ['mime'] = $upload_mime;
  134.     

  135.  
  136.     

  137. }
  138.     

  139.  
  140.     

  141. if ($this->src_fsizes > $this->maxsize) {
  142.     

  143. $this->errver = true;
  144.     

  145. $this->errfile = $i;
  146.     

  147. $this->errno = 40;
  148.     

  149. $this->error = 'UploadFile maxsize too big!';
  150.     

  151. return false;
  152.     

  153. }
  154.     

  155. if (!$this->errver){
  156.     

  157. $savefullpath_array = array();
  158.     

  159. foreach($DstFiles as $key =>$Files){
  160.     

  161. $basename = basename ( $Files['name'], '.'.$Files['type'] );
  162.     

  163. do {
  164.     

  165. eval('$file_savename='.$this->dst_name.';');
  166.     

  167. $file_savefullpath = $this->dst_path . "/" . $file_savename;
  168.     

  169. } while ( file_exists ( $file_savefullpath ) );
  170.     

  171.  
  172.     

  173. if (! move_uploaded_file ( $Files['temp'], $file_savefullpath )) {
  174.     

  175. $this->errver = true;
  176.     

  177. $this->errfile = $i;
  178.     

  179. $this->errno = 50;
  180.     

  181. $this->error = 'UploadFile rename error!';
  182.     

  183. foreach($savefullpath_array as $filesed){
  184.     

  185. delfile($filesed);
  186.     

  187. }
  188.     

  189. unset($savefullpath_array);
  190.     

  191. return false;
  192.     

  193. }else{
  194.     

  195. $DstFiles[$key]['sname'] = $file_savename;
  196.     

  197. $savefullpath_array[] = $file_savefullpath;
  198.     

  199. }
  200.     

  201. }
  202.     

  203. $this->reinfo = $DstFiles;
  204.     

  205. unset($savefullpath_array,$DstFiles,$_FILES);
  206.     

  207. return $DstFiles;
  208.     

  209.  
  210.     

  211. }
  212.     

  213.  
  214.     

  215. }
  216.     

  217.  
  218.     

  219. function str_fillter($string) {
  220.     

  221. $string = str_replace("\\\"", "\"", $string);
  222.     

  223. $string = str_replace("\\'", "'", $string);
  224.     

  225. $string = str_replace("\\\\", "\\", $string);
  226.     

  227. return $string;
  228.     

  229. }
  230.     

  231. }
  232.     

  233. function getfilesux($filename) {
        $stuff = pathinfo ( $filename );
        return $stuff ['extension'];
        }

使用方法:

PHP代码
        

  1. $upload = new FilesUpload();
  2.     

  3. $upload ->dst_path = $uploadpath;
  4.     

  5. $upload -> send($_FILES[upfile]);
  6.     

  7. var_dump ($upload -> reinfo);

 

 

© 2018 技术控 All Rights Reserved