濮阳杆衣贸易有限公司

主頁 > 網(wǎng)站建設 > 建站知識 > dedecms整合百度編輯器(Ueditor)二(圖片上傳路徑問

dedecms整合百度編輯器(Ueditor)二(圖片上傳路徑問

POST TIME:2017-11-13 00:46

上一篇回顧

經(jīng)過努力和摸索上次終于完成了dedecms和百度編輯器(Ueditor)的整合,只是功能不是那么完美。這次主要寫的就是dedecms和ueditor整合優(yōu)化之圖片上傳路徑問題

dedecms整合ueditor后圖片上傳路徑問題

如果按前篇dedecms整合百度編輯器(Ueditor)一(基本整合)整合后也是可以使用圖片上傳,ueditor在線抓圖的,只是圖片會保存到"\include\Ueditor\php\upload"這個目錄下,為了統(tǒng)一想把ueditor編輯器所有上傳、遠程抓取的圖片都保存到"\uploads\allimg\bdimg"

優(yōu)化dedecms整合ueditor后圖片上傳路徑

修改ueditor配置文件/include/ueditor/editor_config.js

找到:,imagePath:URL + "php/"

替換為:,imagePath:"/"

找到:,scrawlPath:URL+"php/"

替換為:,scrawlPath:"/"

找到:URL + "php/"

替換為:,filePath:"/"

找到:,catcherPath:URL + "php/"

替換為:,catcherPath:"/"

找到:,imageManagerPath:URL + "php/"

替換為:,imageManagerPath:"/"

找到:,snapscreenPath: URL + "php/"

替換為:,snapscreenPath: "/"

修改ueditor圖片上傳程序/include/ueditor/php/Uploader.class.php

找到:

$pathStr=$this->config["savePath"];
if(strrchr($pathStr,"/")!="/"){
$pathStr.="/";
}
$pathStr.=date("Ymd");
if(!file_exists($pathStr)){
if(!mkdir($pathStr,0777,true)){
returnfalse;
}
}
return$pathStr;

替換為:

$pathStr=$this->config["savePath"];
$pathStr=str_replace('\\','/',$pathStr);
if(strrchr($pathStr,"/")=="/"){
$pathStr=substr($pathStr,0,-1);
}
$dirpath=explode('/',$pathStr.date('/Ym'));//通過斜杠分割
$dir='';
for($i=0;$i<count($dirpath);$i++)
{
if($i!=count($dirpath))
{
$dir.=$dirpath[$i].'/';
}
if(!file_exists($dir))
{
if(!mkdir($dir,0777,true))returnfalse;
}
}
if(strrchr($dir,"/")=="/"){
$dir=substr($dir,0,-1);
}

/*$pathStr=$this->config["savePath"];
if(strrchr($pathStr,"/")!="/"){
$pathStr.="/";
}
$pathStr.=date("Ymd");
if(!file_exists($pathStr)){
if(!mkdir($pathStr,0777,true)){
returnfalse;
}
}*/
return$dir;



  1. 修改/include/ueditor/php/imageUp.php

    找到:"savePath" => "upload/" ,

    替換為:"savePath" => "../../../uploads/allimg/bdimg" ,

    找到:echo "{'url':'" . $info["url"] . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}";

    替換為:echo "{'url':'" . str_replace('../','',$info[ "url" ]) . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}";

    修改說明:第一處替換就是修改圖片保存路徑的,第二處替換是因為這里用的是相對路徑要把../替換掉,返回給編輯器后就是絕對路徑了。如這里上傳了一張圖片1.jpg,他的路徑就是../../../uploads/allimg/bdimg/201220/1.jpg,結合前面修改editor_config.js的,imagePath:"/"總終路徑就是/../../../uploads/allimg/bdimg/201220/1.jpg,所有這里替換一下。以下的幾個文件修改跟這個是類似的。

  2. 修改ueditor圖片上傳程序/include/ueditor/php/getRemoteImage.php

    找到:"savePath" => "upload/" ,

    替換為:"savePath" => "../../../uploads/allimg/bdimg" ,

    找到://創(chuàng)建保存位置$savePath = $config[ 'savePath' ];if ( !file_exists( $savePath ) ) {mkdir( "$savePath" , 0777 );}

    替換為://創(chuàng)建保存位置

    $savePath = $config[ 'savePath' ];

    $dirpath = explode('/',$savePath.date('/Ym'));//通過斜杠分割

    $savePath = '';

    for($i=0;$i


    {

    if($i != count($dirpath))

    {

    $savePath .= $dirpath[$i].'/';

    }

    if(!file_exists($savePath))

    {

    if(!mkdir($savePath,0777,true))return false;

    }

    }


    找到:echo "{'url':'" . implode( "ue_separate_ue" , $tmpNames ) . "','tip':'遠程圖片抓取成功!','srcUrl':'" . $uri . "'}";

    替換為:echo "{'url':'" . implode( "ue_separate_ue", str_replace('../', '', $tmpNames)) . "','tip':'遠程圖片抓取成功!','srcUrl':'" . $uri . "'}";

    一般編輯用的最多就是圖片上傳和遠程抓圖這兩個功能了,其他如:涂鴉、截屏啥的可以自己做下修改就行了,修改方法跟上面的類似;ueditor那個圖片在線管理目前來看沒什么很大的用處。dedecms整合百度編輯器(Ueditor)

    下一篇預告:dedecms整合百度編輯器(Ueditor)三(織夢使用Ueditor圖片水印問題)

    如有問題可以聯(lián)系QQ:2655101040,一家一起討論



本文來源:genban.org



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
凯里市| 永德县| SHOW| 新蔡县| 武邑县| 门头沟区| 施甸县| 博兴县| 修水县| 大宁县| 九龙坡区| 瑞昌市| 琼中| 河源市| 阿勒泰市| 深圳市| 安康市| 三明市| 罗甸县| 西乌珠穆沁旗| 西乌| 文水县| 南京市| 柳江县| 兴宁市| 巴中市| 虞城县| 南岸区| 济阳县| 阿拉善右旗| 淄博市| 新和县| 永年县| 白朗县| 岐山县| 安龙县| 双城市| 湟源县| 卢湾区| 胶南市| 钟祥市|