百度文本编辑器UMeditor在新浪SAE上的使用

1、下载UMeditor

地址:http://ueditor.baidu.com/website/umeditor.html


2、在UMeditor的目录下有个php文件夹,找到

Uploader.class.php

修改如下:


<span style="font-size:14px;">    private function upFile( $base64 )
    {
        //处理base64上传
        if ( "base64" == $base64 ) {
            $content = $_POST[ $this->fileField ];
            $this->base64ToImage( $content );
            return;
        }

        //处理普通上传
        $file = $this->file = $_FILES[ $this->fileField ];
        if ( !$file ) {
            $this->stateInfo = $this->getStateInfo( 'POST' );
            return;
        }
        if ( $this->file[ 'error' ] ) {
            $this->stateInfo = $this->getStateInfo( $file[ 'error' ] );
            return;
        }
        if ( !is_uploaded_file( $file[ 'tmp_name' ] ) ) {
            $this->stateInfo = $this->getStateInfo( "UNKNOWN" );
            return;
        }

        $this->oriName = $file[ 'name' ];
        $this->fileSize = $file[ 'size' ];
        $this->fileType = $this->getFileExt();

        if ( !$this->checkSize() ) {
            $this->stateInfo = $this->getStateInfo( "SIZE" );
            return;
        }
        if ( !$this->checkType() ) {
            $this->stateInfo = $this->getStateInfo( "TYPE" );
            return;
        }
        
        $folder = '';
        //$folder = $this->getFolder();

        //if ( $folder === false ) {
         //   $this->stateInfo = $this->getStateInfo( "DIR_ERROR" );
        //    return;
        //}
        $fname = $this->getName() ;
        $this->fullName = 'http://您应用名称-upload.stor.sinaapp.com/'.$fname;

        if ( $this->stateInfo == $this->stateMap[ 0 ] ) {
            //if ( !move_uploaded_file( $file[ "tmp_name" ] , $this->fullName ) ) {
            if ($this->uploadFile($fname,$file)==='1') {
            
                $this->stateInfo = $this->getStateInfo( "MOVE" );
            }
        }
    }

    private function uploadFile($fileName,$file){


        $stor   = new SaeStorage();
        $domain = 'upload';//我刚创建的domain的名称
        $url    = NULL;
 
        $fileDataName = $fileName;
        $dumpdata   = file_get_contents($file["tmp_name"]);
        $dowLoadUrl = $stor->write($domain,$fileDataName,$dumpdata);//用write就行了
        $url        = $stor->getUrl($domain,$fileDataName);//如果上传图片的处理地址
        
        if (!$url){
            
            return "1";
            
        }
        else{
            
            return  "0" ;
            
        }
 

    }<span style="white-space:pre">	</span></span>
 

说明:主要是增加uploadFile 方法替换原来的文件保存方式,注释原来的新建文件夹方法


3、修改umeditor.config.js 

   ,imagePath:""                     //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置

这里修改如上,让编辑器取图片绝对路径


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值