好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CI框架简单文件上传总结

一,首先在form表单加上enctype="multipart/form-data"说明该表单用来上传文件

二,特别注意的是,:默认情况下上传的文件来自于提交表单里名为 userfile 的文件域

三,$this->upload->data()这是一个辅助函数,它返回你上传文件的所有相关信息的数组

最后附上上传的方法:



 
	 
		 function   do_upload  ()  
	 
		 {  
	 
		 $config  [  'upload_path'  ]     =     './uploads/'  ;  
	 
		 $config  [  'allowed_types'  ]     =     'gif|jpg|png'  ;  
	 
		 $config  [  'max_size'  ]     =     '100'  ;  
	 
		 $config  [  'max_width'  ]     =     '1024'  ;  
	 
		 $config  [  'max_height'  ]     =     '768'  ;  
	 
		 $this  ->  load  ->  library  (  'upload'  ,   $config  );  
	 
		 $this  ->  upload  ->  do_upload  ();  
	 
		 $data   =   $this  ->  upload  ->  data  ();  
	 
		 $this  ->  load  ->  view  (  'success'  ,   $data  );  
	 
		 }  
	 
		 注意:  $data  是你上传文件的所有相关信息的数组  
 

                    
                    

查看更多关于CI框架简单文件上传总结的详细内容...

  阅读:71次