百度UEditor部署~

1、editor_config.js 路径问题:

先加入函数:

function getRootPath(){
    //获取当前网址,如: http://localhost/jlsh/jlsh/manax/test.html
    var wwwPath=window.document.location.href;
    //获取主机地址之后的目录,如: /jlsh/jlsh/manax/test.html
    var pathName=window.document.location.pathname;
    var pos=wwwPath.indexOf(pathName);
    //获取主机地址,如: http://localhost:8083
    var thePath=wwwPath.substring(0,pos);
    //获取带"/"的项目名,如:/uimcardprj
 var hostname = window.location.host;
 if(hostname=='localhost'||hostname=='127.0.0.1'){
     thePath=thePath+pathName.substring(0,pathName.substr(1).indexOf('/')+1);
 }
 return thePath;

}

配置好UEditor路径,再指定一个上传修正路径。

URL = getRootPath()+'/ueditor/';
upURL = getRootPath()+'/uploads/';

修改下面各个路径,如:

//图片上传配置区
 ,imageUrl:URL+"php/imageUp.php"             //图片上传提交地址
 ,imagePath:upURL  

2、修改文件 image.html

去除图片“选择保存目录”

ueditor\dialogs\image\image.html

59行  

192行

//var postParams = {
//    "dir":baidu.g("savePath").value
// };
//imageUploader.setPostParams(postParams);
flashObj.upload();
this.style.display = "none";
//$G("savePath").parentNode.style.display = "none";

3、修改上传文件

Uploader.class.php //上传类会被各个文件调用,在头部加上一个获取根目录的变量。

$uprootpath = dirname(dirname(dirname(dirname(__FILE__)))).'/uploads/t/';

其它文件调用时$config数组里加入:

"rootpath" => $uprootpath,

97行左右:if ( !move_uploaded_file( $file[ "tmp_name" ] , $this->config[ "rootpath" ].$this->fullName ) ) {

113行左右:if ( !file_put_contents( $this->config[ "rootpath" ].$this->fullName , $img ) ) {

195行左右:if ( !file_exists( $this->config[ "rootpath" ].$pathStr ) ) {
            if ( !mkdir( $this->config[ "rootpath" ].$pathStr , 0777 , true ) ) {

imageUp.php //图片上传类

13行://$path = htmlspecialchars($_POST['dir'], ENT_QUOTES);  //注释掉

$config = array(
  "rootpath" => $uprootpath,
  //"savePath" => ($path == "1" ? "upload/" : "upload1/"),
  "savePath" => "img/",
  "maxSize" => 1000, //单位KB
  "allowFiles" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp")
);

scrawlUp.php //涂鸦图片上传

6行:

$config = array(
    "rootpath" => $uprootpath,
    "savePath" => "timg/"
            //存储文件夹
    "maxSize" => 1000 ,                   //允许的文件最大尺寸,单位KB
    "allowFiles" => array( ".gif" , ".png" , ".jpg" , ".jpeg" , ".bmp" )  //允许的文件格式
);

imageManager.php //图片文件浏览

13行://$paths = array('upload/','upload1/');
 $path = dirname(dirname(dirname(dirname(__FILE__)))).'/uploads/t/img/';

19行://foreach ( $paths as $path){
            $tmp = getfiles( $path );
            if($tmp){
                $files = array_merge($files,$tmp);
            }
        //}

getRemoteImage.php //远程抓取图片

13行:$config = array(
        "rootpath" => dirname(dirname(dirname(dirname(__FILE__)))).'/uploads/t/',
        //"savePath" => "upload/" ,            //保存路径
        "savePath" => "img/",
        "allowFiles" => array( ".gif" , ".png" , ".jpg" , ".jpeg" , ".bmp" ) , //文件允许格式
        "maxSize" => 3000                    //文件大小限制,单位KB
    );

78行:$savePath = $config[ 'savePath' ];
            if ( !file_exists( $config[ 'rootpath' ].$savePath ) ) {
                mkdir( $config[ 'rootpath' ].$savePath , 0777 );
            }

85行:$fp2 = @fopen( $config[ 'rootpath' ].$tmpName , "a" );

fileUp.php //文件上传类

13行:$config = array(
        "rootpath" => $uprootpath,
        "savePath" => "files/" , //保存路径
        "allowFiles" => array( ".rar" , ".doc" , ".docx" , ".zip" , ".pdf" , ".txt" , ".swf" , ".wmv" ) , //文件允许格式
        "maxSize" => 100000 //文件大小限制,单位KB
    );

 

上传后保存的完整的URL,后台写一个函数来过滤一下上传的内容。

//获取网站根目录
function curPageURL()
{
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on")
    {
        $pageURL .= "s";
    }
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80")
    {
        $pageURL .= $_SERVER["SERVER_NAME"].":" . $_SERVER["SERVER_PORT"];
    }
    else
    {
        $pageURL .= $_SERVER["SERVER_NAME"];
    }
 if ($_SERVER["SERVER_NAME"] =="localhost"||$_SERVER["SERVER_NAME"] == "127.0.0.1"){
  $phpself = $_SERVER['PHP_SELF'];
  $pageURL .= substr($phpself,0,strpos($phpself,'/',1));
 }
    return $pageURL;
}
//处理上传内容
function doContent($str){
 if(get_magic_quotes_gpc())//如果get_magic_quotes_gpc()是打开的
 {
  $str=stripslashes($str);//将字符串进行处理
 }
 $rooturl = curPageURL();
 $str=str_replace($rooturl,'',$str);
 return $str;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值