【问题标题】:how to add path to image uploader plugin in ckeditor in Codeigniter?如何在 Codeigniter 的 ckeditor 中添加图片上传插件的路径?
【发布时间】:2017-02-24 11:24:18
【问题描述】:

我已经添加了ckeditor的图片上传插件,谁能告诉我如何添加浏览服务器路径?我正在使用 Coedigniter 并将文件夹保存在 assets 中。 我在网上找到了一些东西说你可以添加

plugins->imageuploader->plugin.js

在 plugin.js 中

CKEDITOR.plugins.add( 'imageuploader', {
    init: function( editor ) {
        editor.config.filebrowserBrowseUrl = 'ckeditor/plugins/imageuploader/imgbrowser.php';
    }
});

我找到了这些。现在,当我单击添加图像并单击 Browse Server 时,它会抛出 404 Not found。

我什至在问题上附加了一张图片。 Image of a problem

【问题讨论】:

标签: php ckeditor codeigniter-3


【解决方案1】:

这是在文件浏览器中选择文件时返回ckeditor路径的jquery代码

$(document).ready(function() {
  var funcNum = <?php echo $_GET['CKEditorFuncNum'].';'; ?>
  $('#fileList-wrapper').on('click', 'img', function() {
    var fileUrl = $(this).attr('data-id');
    window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl);
    window.close();
  });
});

在文件浏览器中显示文件的文件 php 代码

<div id="fileList-wrapper">
<?php 
    $fileList = glob('assets/uploads/*');
    foreach($fileList as $fileName){
    ?>
        <div class="thumbnail">
        <img src="<?= base_url().$fileName?>" data-id="<?= base_url().$fileName?>" width="140" height="120"/>
                        <br />
                        <?= $fileName ?>
                    </div>
                <?php
            }
            ?>
        </div>

这里是需要添加到文件中的js文件

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdn.ckeditor.com/4.6.2/full-all/ckeditor.js"></script>

您可能需要添加 css 样式

【讨论】:

    猜你喜欢
    • 2020-08-03
    • 2020-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-30
    • 2011-12-28
    • 1970-01-01
    • 2021-12-14
    相关资源
    最近更新 更多