首頁 >php教程 >php手册 >黄永成老师thinkphp视频教程ueditor最新版本使用

黄永成老师thinkphp视频教程ueditor最新版本使用

WBOY
WBOY原創
2016-06-07 11:41:401591瀏覽

视频教程上的ueditor和最新版本不太一样,今天弄了好长时间,终于可以成功上传了。现在给大家分享一下。
配置项处做一下修改,如下:<script><br /> window.UEDITOR_HOME_URL = &#039;__ROOT__/Data/Ueditor/&#039;;<br /> window.onload = function () {<br /> window.UEDITOR_CONFIG.initialFrameWidth = 1200;<br /> window.UEDITOR_CONFIG.initialFrameHeight = 600;<br /> window.UEDITOR_CONFIG.serverUrl = "{:U(GROUP_NAME.&#039;/Blog/upload&#039;)}";<br /> UE.getEditor(&#039;content&#039;);<br /> }<br /> <br /> </script>upload()做了较大的修改,主要是把新版本ueditor的controller.php文件复制过来进行了一下修改。//编辑器图片上传处理<br>     public function upload () {<br>         date_default_timezone_set("Asia/chongqing");<br>         error_reporting(E_ERROR);<br>         header("Content-Type: text/html; charset=utf-8");<br>         <br>         $CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents("./Data/Ueditor/php/config.json")), true);<br>         $action = $_GET['action'];<br>         switch ($action) {<br>             case 'config':<br>                 $result =  json_encode($CONFIG);<br>                 break;<br>         <br>                 /* 上传图片 */<br>             case 'uploadimage':<br>                 /* 上传涂鸦 */<br>             case 'uploadscrawl':<br>                 /* 上传视频 */<br>             case 'uploadvideo':<br>                 /* 上传文件 */<br>             case 'uploadfile':<br>                 //$result = include("action_upload.php");<br>                 import('ORG.Net.UploadFile');<br>                 $upload = new UploadFile();<br>                 $upload->autoSub = true;<br>                 $upload->subType = 'date';<br>                 $upload->dateFormat = 'Ym';<br>                 if ($upload->upload('./Uploads/')){<br>                     $info = $upload->getUploadFileInfo();<br>                     echo json_encode(array(<br>                             'url'        =>    __ROOT__.'/Uploads/'.$info[0]['savename'],<br>                             'title'        =>    htmlspecialchars($_POST['pictitle'], ENT_QUOTES),<br>                             'original'    =>    $info[0]['name'],<br>                             'state'        =>    'SUCCESS'<br>                             ));<br>                     <br>                 }else{<br>                     echo json_encode(array(<br>                             'state'    => $upload->getErrorMsg(),<br>                             ));<br>                 }<br>                 break;<br>         <br>                 <br>         }<br>         <br>         /* 输出结果 */<br>         if (isset($_GET["callback"])) {<br>             if (preg_match("/^[\w_]+$/", $_GET["callback"])) {<br>                 echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';<br>             } else {<br>                 echo json_encode(array(<br>                         'state'=> 'callback参数不合法'<br>                 ));<br>             }<br>         } else {<br>             echo $result;<br>         }<br>     }这样上传图片就正常了,大家试一下,如果有问题可以留言共同讨论。

AD:真正免费,域名+虚机+企业邮箱=0元

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn