1、CKEditor 不具备上传功能,需要集成 CKFinder 才能实现上传功能。
下载:CKEditor: ,并解压到 ckeditor(在根目录下); CKFinder :,并解压到 ckfinder (在根目录下); 两者处于同级目录下; 把ckfinder目录里的bin下的CKFinder.dll拷贝到网站目录bin下。2、在 aspx 页面ckeditor.js:
<scripttype="text/javascript"src="ckeditor/ckeditor.js"></script>(个人使用并不需要引用ckfinder.js) 在<body>标签中使用ckeditor: <textarea cols="80" name="editor1" rows="10" id="editor1"></textarea>下面这段必须放在上面代码的后面,否则初始化编辑器时会错误:
<script type="text/javascript"> var editor = CKEDITOR.replace("editor1"); </script>3.
ckeditor里面的config.js 配置
CKEDITOR.editorConfig = function( config )
{ config.filebrowserBrowseUrl= '/ckfinder/ckfinder.html'; //上传文件时浏览服务文件夹config.filebrowserImageBrowseUrl= '/ckfinder/ckfinder.html?Type=Images'; //上传图片时浏览服务文件夹
config.filebrowserFlashBrowseUrl= '/ckfinder/ckfinder.html?Type=Flash'; //上传Flash时浏览服务文件夹
config.filebrowserUploadUrl = '/ckfinder/core/connector/aspx/connector.aspx?
command=QuickUpload&type=Files'; //上传文件按钮(标签)
config.filebrowserImageUploadUrl= '/ckfinder/core/connector/aspx/connector.aspx?
command=QuickUpload&type=Images'; //上传图片按钮(标签)
config.filebrowserFlashUploadUrl= '/ckfinder/core/connector/aspx/connector.aspx?
command=QuickUpload&type=Flash'; //上传Flash按钮(标签)
config.language = 'zh-cn';//中文 config.uiColor = '#BFEE62';//编辑器颜色 config.font_names = '宋体;楷体_GB2312;新宋体;黑体;隶书;幼圆;微软雅黑;Arial;Comic Sans MS;CourierNew;Tahoma;Times New Roman;Verdana';
config.toolbar_Full =
[ ['Source','-','Preview','-','Templates'], ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton','HiddenField'],
'/', ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'], '/', ['Styles','Format','Font','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks','-','About'] ];config.toolbar_Basic =
[ ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','About'] ];config.width =771;//宽度
config.height = 250;//高度
};4、ckfinder下 config.ascx
(1)CheckAuthentication()函数return true;(网上说不安全,可以自己设置)(2)BaseUrl = "/ckfinder/userfiles/"; 如果各个用户有自己的目录,就再这改 //BaseUrl = "/ckfinder/userfiles/" + sup_id + "/images/";5.ckeditor不自带行高,如果想添加行高,添加 lineheight。具体用法: