当前位置:首页 > CMS教程 > Thinkphp > 列表

thinkphp 获取上传文件信息

发布:smiling 来源: PHP粉丝网  添加日期:2014-07-23 14:55:09 浏览: 评论:0 
  1. //文件上传 
  2.     public function files(){ 
  3.         if(!emptyempty($_POST)){ 
  4.             $data['remark']      = $this->_post('remark'); 
  5.                
  6.               import('ORG.Net.UploadFile'); 
  7.               $upload = new UploadFile(); 
  8.               $upload->savePath =  './Public/uploads/files/'
  9.                $upload->saveRule =  ''
  10.               if(!$upload->upload()) { 
  11.                   $this->error($upload->getErrorMsg()); 
  12.               }else
  13.                   $info =  $upload->getUploadFileInfo(); 
  14.               } 
  15.                
  16.               foreach ($info as $key => $val) { 
  17.                   $data['title']=$val['savename']; 
  18.                   $data['type']=$val['type']; 
  19.                   $data['size']=$val['size'];     
  20.                   $data['url']=$val['savepath']; 
  21.               } 
  22.               $data['addtime']=time(); 
  23.               $data['aid']=$_SESSION['admin_info']['user_id']; 
  24.               $list=M("upload_files")->add($data); 
  25.               if($list){ 
  26.                   $this->success("文件上传成功!",U('Upload/fileslist')); 
  27.  
  28.               }else
  29.                   $this->error("文件上传失败!"); 
  30.               } 
  31.                
  32.         }else
  33.             $this->display(); 
  34.         } 
  35.     } 

Tags: thinkphp 获取上传文件

分享到: