主页 > 网站建设 > 建站知识 > dedecms整合百度编辑器(Ueditor)二(图片上传路径问

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



收缩
  • 微信客服
  • 微信二维码
  • 电话咨询

  • 400-1100-266