封装好的ueditor-美化版

/**
 * 富文本编辑器图片上传
 */
public function upimgAction(){
    if($_GET['action'] == 'config'){
        echo '{
            "imageActionName": "uploadimage",
            "imageFieldName": "upfile",
            "imageMaxSize": 2048000,
            "imageAllowFiles": [
                            ".png",
                            ".jpg",
                            ".jpeg",
                            ".gif"
                        ],
            "imageUrlPrefix": "",
        }';
    }else{
        $upload_url = Yaf_Application::app()->getConfig()->url->uploads;
        $result='0';
        $fileElementName = 'upfile';
        if(!empty($_FILES[$fileElementName]['tmp_name']) || $_FILES[$fileElementName]['tmp_name'] != 'none'){
            $config = C('PICTURE_UPLOAD');
            $arrType = explode(",",$config['exts']);
            $upload = new Upload();// 实例化上传类
            $upload->maxSize   =     $config['maxSize'];// 设置附件上传大小
            $upload->exts      =     $arrType;// 设置附件上传类型

            $upload->rootPath  =  '../uploads/'; // 设置附件上传根目录
            $upload->savePath  =  'attachment/'; // 设置附件上传(子)目录

            // 上传文件
            /*{"state":"SUCCESS","url":"\/ueditor\/php\/upload\/image\/20150716\/1437014899972910.png","title":"1437014899972910
            .png","original":"cy_pub.png","type":".png","size":2583}*/
            $info   =   $upload->upload();
            if(!$info) {
                // 上传错误提示错误信息
                $result='ERROR';
                $path = '';
            }else{
                $result='SUCCESS';
                $re=$info[$fileElementName];
                $path = $upload_url.$re['savepath'].$re['savename'];

            }
        }
        echo json_encode(array('state'=>$result,'url'=>$path,'title'=>$re['savename'],'original'=>$re['name'],'type'=>'.'.$re['ext'],'size'=>''));
    }

    exit;
}

美化后的百度编辑器:
image

链接: https://pan.baidu.com/s/1C6UYzyu8Et1AhE9IOf3F-A 密码: xhr2