我正在尝试使用 yii2 将 ckeditor 和 ckfinder 集成到项目中。 我已将 ckeditor 和 ckfinder 文件夹放在 root/vendor 中并进行了必要的调整,ckeditor 工作正常,ckfinder 还显示带有“浏览器服务器”按钮的文件浏览器弹出窗口。但每当我单击浏览按钮时,它都不会打开文件选择器弹出窗口,而是显示页面未找到错误。
我尝试集成 ckfinder,在 ckeditor/config.js 中编写以下代码行:
config.filebrowserBrowseUrl = 'hostname/vendor/ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = 'hostname/vendor/ckfinder/ckfinder.html?type=Images';
config.filebrowserFlashBrowseUrl = 'hostname/vendor/ckfinder/ckfinder.html?type=Flash';
config.filebrowserUploadUrl = 'hostname/vendor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
config.filebrowserImageUploadUrl = 'hostname/vendor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';
config.filebrowserFlashUploadUrl = 'hostname/vendor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';
但是我还没有找到解决办法。
有人可以帮我解决这个问题吗?
我在 yii2 中创建自定义 CKEditorAsset,如下所示:
namespace vendor\yiif\ckeditor;
use iutbay\yii2kcfinder\KCFinder;
use iutbay\yii2kcfinder\KCFinderAsset;
class CKEditorAsset extends \dosamigos\ckeditor\CKEditorAsset
{
public $depends = [
'yii\web\YiiAsset',
'yii\web\JqueryAsset',
//'iutbay\yii2kcfinder\KCFinderAsset'
];
public function init()
{
$register = KCFinderAsset::register(\Yii::$app->view);
$kcfinderUrl = $register->baseUrl;
\Yii::$app->view->registerJs(<<<js
CKEDITOR.config.filebrowserBrowseUrl="$kcfinderUrl/browse.php?opener=ckeditor&type=files";
CKEDITOR.config.filebrowserUploadUrl="$kcfinderUrl/upload.php?opener=ckeditor&type=files";
js
);
// kcfinder options
// http://kcfinder.sunhater.com/install#dynamic
$kcfOptions = array_merge(KCFinder::$kcfDefaultOptions, [
'uploadURL' => \Yii::getAlias('@web/uploads/modules/ckfinder'),
'uploadDir'=>\Yii::getAlias('@app/web/uploads/modules/ckfinder'),
'access' => [
'files' => [
'upload' => true,
'delete' => false,
'copy' => false,
'move' => false,
'rename' => false,
],
'dirs' => [
'create' => true,
'delete' => false,
'rename' => false,
],
],
]);
// Set kcfinder session options
\Yii::$app->session->set('KCFINDER', $kcfOptions);
parent::init();
}
}