资源描述:
《thinkphp3.2实现上传图片的掌握器方法_》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、thinkphp3.2实现上传图片的掌握器方法_本文讲解并描述了thinkphp3.2实现上传图片的掌握器方法。分享给大家供大家参考,具体如下:publicfunctionfile(){$baseUrl=str_replace('\','/',dirname($_SERVER['SCRIPT_NAME']));import('ORG.Net.UploadFile');import('ORG.Util.Services_JSON');$upload=newUploadFile();$upload-maxSize=3145728;$upload-allowExts=array(
2、'jpg','gif','png','jpeg');$upload-savePath='./uploads/Images/';$info=$upload-uploadOne($_FILES['imgFile']);$file_url=$baseUrl.'uploads/Images/'.$info['0']['savename'];if($info){header('Content-type:text/html;charset=UTF-8');$json=newServices_JSON();echo$json-encode(array('error'=0,'url'=$fi
3、le_url));exit;}else{$this-error($upload-getErrorMsg());}}publicfunctionfile_manager(){import('ORG.Util.Services_JSON');$php_path=dirname(__FILE__).'/';$php_url=dirname($_SERVER['PHP_SELF']).'/';$root_path=$php_path.'./uploads/Images/';$root_url=$php_url.'./uploads/Images/';$ext_arr=array('g
4、if','jpg','jpeg','png','bmp');$dir_name=emptyempty($_GET['dir'])?'':trim($_GET['dir']);if(!in_array($dir_name,array('','image','flash','media','file'))){echo"InvalidDirectoryname.";exit;}if($dir_name!==''){$root_path.=$dir_name."/";$root_url.=$dir_name."/";if(!file_exists($root_path)){mkdir
5、($root_path);}}//依据path参数,设置各路径和URLif(emptyempty($_GET['path'])){$current_path=realpath($root_path).'/';$current_url=$root_url;$current_dir_path='';$moveup_dir_path='';}else{$current_path=realpath($root_path).'/'.$_GET['path'];$current_url=$root_url.$_GET['path'];$current_dir_path=$_GET['pa
6、th'];$moveup_dir_path=preg_replace('/(.*?)[^/]+/$/','$1',$current_dir_path);}echorealpath($root_path);//排序形式,nameorsizeortype$order=emptyempty($_GET['order'])?'name':strtolower($_GET['order']);//不允许用法..移动到上一级名目if(preg_match('/../',$current_path)){echo'Accessisnotallowed.';exit;}//最终一个字符
7、不是/if(!preg_match('//$/',$current_path)){echo'Parameterisnotvalid.';exit;}//名目不存在或不是名目if(!file_exists($current_path)
8、
9、!is_dir($current_path)){echo'Directorydoesnotexist.';exit;}//遍历名目取得文件信息$file_list=array();if($handle=opendir($current_path)){$i=0;while