• 全国400电话网上服务平台
    强大号码库资源任选,方便,快捷,快速开通。
    咨询热线:400-1100-266  

    dedecms整合百度编辑器(Ueditor)二(图片上传路径问
    POST TIME:2017-11-13 00:46

    上一篇回顾

    经过努力和摸索上次终于完成了dedecms和百度编辑器(Ueditor)的整合,只是功能不是那么完美。这次主要写的就是dedecms和ueditor整合优化之图片上传路径问题

    dedecms整合ueditor后图片上传路径问题

    如果按前篇dedecms整合百度编辑器(Ueditor)一(基本整合)整合后也是可以使用图片上传,ueditor在线抓图的,只是图片会保存到"\include\Ueditor\php\upload"这个目录下,为了统一想把ueditor编辑器所有上传、远程抓取的图片都保存到"\uploads\allimg\bdimg"

    优化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" ,

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

      替换为://创建保存位置

      $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图片水印问题)

      如有问题可以联系QQ:2655101040,一家一起讨论



    本文来源:genban.org

    
    Copyright © 2003-2016
    时间:9:00-21:00 (节假日不休)
    版权所有:巨人网络(扬州)科技有限公司
    总部地址:江苏省信息产业基地11号楼四层
    《增值电信业务经营许可证》 苏B2-20120278
    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信

    微信号已复制,请打开微信添加咨询详情!