百度php editor图片上传到其他盘,dedecms整合百度编辑器(Ueditor)二(图片上传路径问题)...

上一篇回顾

经过努力和摸索上次终于完成了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 ) ) {

return false;

}

}

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

{

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

{

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

}

if(!file_exists($dir))

{

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

}

}

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 ) ) {

return false;

}

}*/

return $dir;

修改/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,所有这里替换一下。以下的几个文件修改跟这个是类似的。

修改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 ad51e517755f8fd6a7ec83ced4ecfaf3.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值