1.在使用ueditor時(shí)加載編輯器成功,但使用圖片功能時(shí)總是報(bào)錯(cuò)(類型:上傳錯(cuò)誤,但圖片上傳到目錄里了)?采用的是前臺(tái)加載編輯器-->serverURL:xx/xx/xx(think里寫的一個(gè)上傳方法)Ps:編輯器默認(rèn)2.大家是怎么通過(guò)使用tp里的upload方法接收編輯器內(nèi)容并且編輯器里圖片正常顯示(重點(diǎn))Ps:僅僅正常引用ueditortp控制上傳思路,希望能參考下代碼ueditor是最新版的,config.js中不存在imageURL:xxx更新:解決了圖片上傳問(wèn)題,upload方法采用control.php的代碼(有更簡(jiǎn)潔方法,可以留言).Ps:新手代碼:javascript$(function(){varue=UE.getEditor('editor',{UEDITOR_HOME_URL:'__PUBLIC__/admin/ueditor/',initialFrameHeight:500,serverUrl:'{:U('Admin/Edit/upload')}'});})phppublicfunctionupload(){date_default_timezone_set("Asia/Chongqing");error_reporting(E_ERROR);header("Content-Type:text/html;charset=utf-8");$CONFIG=json_decode(preg_replace("/\/\*[\s\S]+?\*\//","",file_get_contents("./Public/Admin/Ueditor/php/config.json")),true);$action=htmlspecialchars($_GET['action']);/*實(shí)例化上傳類*/$upload=new\Think\Upload();$upload->rootPath='./Public';$viewPath=__ROOT__.'/Public';//長(zhǎng)傳后,編輯器顯示路徑switch($action){case'config':$result=json_encode($CONFIG);break;/*上傳圖片*/case'uploadimage':$upload->maxSize=2048000;$upload->exts=array('jpg','gif','png','jpeg');$upload->savePath='/Uploads/img/';$info=$upload->upload();if($info){$data=array('state'=>'SUCCESS',//上傳狀態(tài)'url'=>$viewPath.$info['upfile']['savepath'].$info['upfile']['savename'],//返回地址'title'=>$info['upfile']['savename'],//新文件名'original'=>$info['upfile']['name'],//原文件名'type'=>$info['upfile']['ext'],//文件擴(kuò)展名'size'=>$info['upfile']['size'],//文件大小);}else{$data=array('state'=>$upload->getError(),);}$result=json_encode($data);break;.....if(isset($_GET["callback"])){if(preg_match("/^[\w_]+$/",$_GET["callback"])){echohtmlspecialchars($_GET["callback"]).'('.$result.')';}else{echojson_encode(array('state'=>'callback參數(shù)不合法'));}}else{echo$result;}但是這個(gè)代碼只能解決圖片問(wèn)題,視頻上傳后會(huì)返回服務(wù)器錯(cuò)誤(很不理解為啥這樣)歡迎指正:)
Thinkphp如何使用ueditor編輯器時(shí)
ABOUTYOU
2019-04-07 11:18:37