那个在配置文件中默认配置,毫无安全验证,所以自定自定义了下安全验证。
<?php
namespace wx\controllers;
use Yii;use yii\filters\AccessControl;
use yii\imagine\Image;
use yii\web\Controller;
//这两文件主要完成后台工作,那个包下的其它文件完成前台的工作
use \crazydb\ueditor\Uploader;
use \crazydb\ueditor\UEditorController;
class EditorController extends UEditorController
{
//简单的权限检查
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
//登录用户可以访问的视图动作,如果开启了rbac,那就用beforeAction()进行一对一权限检查
'actions' => [
'index', 'config', 'upload-image', 'upload-scrawl', 'upload-file',
'list-image', 'list-file', 'catch-image', 'list-info'
],
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
/**
* @see 需要重写优化的方法,我们在这里重写,其它的则继续使用原来的方法
**/
public function init()
{
parent::init();
// 图片缩放设置,也类似最大边控制一样,反正这个编辑器BUG还是太多了,好多肯
$this->zoom = ['height' => 800, 'width' => 800];
// 考虑到 网站访问量小,尤其同时使用的人少,还是不要后面的8位随机数了,方便图片管理
$default = [
'imagePathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}',
'scrawlPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}',
'snapscreenPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}',
'catcherPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}',
'videoPathFormat' => '/upload/video/{yyyy}{mm}{dd}/{time}',
'filePathFormat' => '/upload/file/{yyyy}{mm}{dd}/{filename}',
'imageManagerListPath' => '/upload/image/',
'fileManagerListPath' => '/upload/file/',
];
$this->config = $default + $this->config;
}
}这是控制器的更改,视图文件中config项中把serverUrl 改过来
'serverUrl' => ['/editor/index'],
就这么简单,目前接口还是一样的,如果需要自定义接口,或者增加不同需求的接口,那就继续写action就可以了。