首页 > 开发 > ThinkPHP > 正文

thinkphp 获取上传文件信息

2024-09-09 15:20:14
字体:
来源:转载
供稿:网友
  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.     } 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选