我正在为yii2 https://packagist.org/packages/wadeshuler/yii2-ckeditor-cdn
使用此ckeditor扩展程序我创建了目录后端/ web / uploads / images并为他们提供了权利777
我像这样配置了backend / config / main.php
'modules' => [
'ckeditor' => [
'class' => 'wadeshuler\ckeditor\Module', // required and dont change!!!
'uploadDir' => '@app/web/uploads', // must be file path (required when using filebrowser*BrowseUrl below)
'uploadUrl' => '@web/uploads', // must be valid URL (required when using filebrowser*BrowseUrl below)
// These are basically passed to the `CKEDITOR.replace()`
'widgetClientOptions' => [
'filebrowserImageBrowseUrl' => '/ckeditor/default/image-browse',
'filebrowserImageUploadUrl' => '/ckeditor/default/image-upload',
]
],
],
加入表格
use wadeshuler\ckeditor\widgets\CKEditor;
<?= $form->field($model, 'body')->widget(CKEditor::className()) ?>
当我上传图片并单击“将其发送到服务器”时,它不会上传,当我点击“确定”时,它表示图像源网址丢失。
也许以前有人遇到过这个问题? 顺便说一句,如果我删除这些行
//'uploadDir' => '@app/web/uploads', // must be file path (required when using filebrowser*BrowseUrl below)
//'uploadUrl' => '@web/uploads', // must be valid URL (required when using filebrowser*BrowseUrl below)
没有任何改变。同样的错误。
答案 0 :(得分:0)
here是我找到的解决方案,请参阅链接并参见示例3部分
看起来像这样:
// Required: anonymous function reference number as explained above.
$funcNum = $_GET['CKEditorFuncNum'] ;
// Optional: instance name (might be used to load a specific configuration file or anything else).
$CKEditor = $_GET['CKEditor'] ;
// Optional: might be used to provide localized messages.
$langCode = $_GET['langCode'] ;
// Check the $_FILES array and save the file. Assign the correct path to a variable ($url).
$url = '/path/to/uploaded/file.ext';
// Usually you will only assign something here if the file could not be uploaded.
$message = '';
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>";
你应该注意filebrowserUploadUrl
选项必须指向处理上传图像的yii函数,在这种情况下看起来像上面的示例代码。并且不要忘记在uploadimage
个选项上添加filebrowser
和extraPlugins
。