zoukankan      html  css  js  c++  java
  • ckeditor上传图片的注意点

    1、要在 ckeditor的  config.js 文件中加上

    CKEDITOR.editorConfig = function( config ) {

        config.filebrowserImageUploadUrl = 'ckEditImageUpload';//上传图片的接口
    };

    2、实现上传接口

        @RequestMapping(value = "ckEditImageUpload", method = RequestMethod.POST)
        @ResponseBody
        public String ckEditImageUpload(MultipartHttpServletRequest request,HttpServletResponse response) throws BaseException
        {
            String fullPath = null;
            String callback = request.getParameter("CKEditorFuncNum");
            MultipartFile file = request.getFile("upload");
            fullPath = uploadService.getFileUrl(file);
            response.setContentType("text/html;charset=UTF-8");
            response.setHeader("X-Frame-Options", "SAMEORIGIN");
            return "<script type='text/javascript'>"
            + "window.parent.CKEDITOR.tools.callFunction(" + callback
            + ",'" + fullPath + "',''" + ")"+"</script>";
        }

    另在页面中插入ckeditor:

    引入js   <script type="text/javascript" src="${rootURL}resources/ckeditor/ckeditor.js"></script>

    替换

        <td colspan="3">

                    <textarea name="content" id="content" rows="10" cols="40">${banner.content}</textarea>
                    <script>
                        // Replace the <textarea id="editor1"> with a CKEditor
                        // instance, using default configuration.
                        CKEDITOR.replace('content');
                    </script>
                    </td>

  • 相关阅读:
    蚂蚁问题
    LinuxC安装gcc
    怎样在VC里面使用graphics.h绘图
    C语言之固定格式输出当前时间
    C语言之猜数字游戏
    C语言之新同学年龄
    C语言之ASCII码
    C语言之辗转相除法
    C语言之自守数
    C语言之一数三平方
  • 原文地址:https://www.cnblogs.com/yousen/p/4736470.html
Copyright © 2011-2022 走看看