要解决dedecms整合百度编辑器(Ueditor)图片上传路径问题,需要修改UEditor的配置文件和dedecms的数据调用方式。
在整合dedecms和百度编辑器(Ueditor)的过程中,图片上传路径问题是一个常见的优化需求,以下将详细阐述如何修改配置以解决图片上传路径问题:
图片上传路径问题及解决方法
1、修改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:"/"
2、修改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<count($dirpath);$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);       }       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"] . "'}";
文件位置:/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<count($dirpath);$i++)       {           if($i != count($dirpath))           {               $savePath .= $dirpath[$i].'/';           }           if(!file_exists($savePath))           {               if(!mkdir($savePath,0777,true))return false;           }       }相关问答FAQs
1、Q: 为什么要修改Ueditor的图片上传路径?
A: 默认情况下,Ueditor的图片会保存到“includeUeditorphpupload”目录下,这可能不符合网站的实际需求,为了统一管理,通常会希望将所有上传的图片保存到一个特定的目录,如“uploadsallimgbdimg”,需要修改配置文件和程序代码来实现这一目标。
2、Q: 修改后的图片上传路径是否会影响已有的图片显示?
A: 是的,如果直接修改路径而不考虑已有图片的迁移,可能会导致原有图片无法正常显示,在修改路径前,应确保所有引用这些图片的路径也同步更新,或者使用软链接等方式来保持原有图片的可访问性。

QQ客服