相思资源网 Design By www.200059.com
本文讲述了thinkphp3.2实现上传图片的控制器方法。分享给大家供大家参考,具体如下:
public function file() { $baseUrl = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); import('ORG.Net.UploadFile'); import('ORG.Util.Services_JSON'); $upload = new UploadFile(); $upload->maxSize = 3145728; $upload->allowExts = array('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 = new Services_JSON(); echo $json->encode(array('error' => 0, 'url' => $file_url)); exit; } else { $this->error($upload->getErrorMsg()); } } public function file_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('gif', 'jpg', 'jpeg', 'png', 'bmp'); $dir_name = emptyempty($_GET['dir']) "Invalid Directory name."; exit; } if ($dir_name !== '') { $root_path .= $dir_name . "/"; $root_url .= $dir_name . "/"; if (!file_exists($root_path)) { mkdir($root_path); } } //根据path参数,设置各路径和URL if (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['path']; $moveup_dir_path = preg_replace('/(.*"_blank" href="https://www.jb51.net/Special/39.htm">ThinkPHP入门教程》、《ThinkPHP常用方法总结》、《smarty模板入门基础教程》及《PHP模板技术总结》。希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无thinkphp3.2实现上传图片的控制器方法的评论...