谁能告诉我怎样在ASP CKEditor 中实现上传图片功能
2015-08-02 · 知道合伙人数码行家
1、项目先新建Lbrary文件夹跟js文件夹(js小写)并在js文件夹下,在简历ckeditor和ckfinder文件夹,压缩包找到其中/bin/Debug下的CKEditor.NET.dll考到新建的文件夹下,如后在引用中右键添加对刚才的CKEditor.NET.dll的引用,如图:
2、将压缩包中的_Sample的ckeditor文件夹下的9个文件考到js文件夹下的ckeditor里连同,如图:
3、在aspx网页中注册CKEditor插件:
第一种一种方式是在单个网页的顶部添加下面的语句如果要在单个网页中使用该插件则在该网页到最上面添加
<%@Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor"%>
第二种方式是在整个工程的Web.config文件的
<system.web><pages><controls>中添加<add tagPrefix="CKEditor" assembly="CKEditor.NET" namespace="CKEditor.NET"/>
4、把ckfinder文件下的4个问价考到ckfinder文件夹里,如图:
5、修改ckeditor下的config.js文件,在其添加如下代码,如图:
var ckfinderPath = "/js"; config.filebrowserBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html'; config.filebrowserImageBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html?type=Images'; config.filebrowserFlashBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html?type=Flashs'; config.filebrowserUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&Type=Files'; config.filebrowserImageUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&Type=Images'; config.filebrowserFlashUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&Type=Flash';
6、修改ckfinder下的config.ascx 文件,把return false 给为return true即可,如图:
2,将ckfinder解压,ckfinder文件夹拷贝项目中的根目录下,把bin放在根目录下,把_sample,_source,help文件夹删除掉,(注:没有用)
3,在ckeditor文件下找到config.js 打开,找到
在CKEDITOR.editorCongig=function(config)
{
//填写以下内容,图片,flash路径
config.uiColor = '#F7F8F9'
config.scayt_autoStartup = false
config.language = 'zh-cn'; //中文
config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=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';
};
4,在ckfinder文件下找到config.ascx文件,打开
1)把public overrider bool ChekcAuthentication(){return false;改为:return true;}
2)public overrider void SetConfig(){BaseUrl = "~/ckfinder/userfiles/";}
5,在页面中head标签内写入:
<script type="text/javascript" src="ckeditor/ckeditor.js" ></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
如果有母版页,在母版页中写
--注:单纯的配置,6,7可以不要,但是一旦要入数据库中,就要配置6.7步骤
6,在Default.aspx页面中,写入<%@Page ValidateRequest="false"%>
7,在web.config文件中,在system.web下写 <httpRuntime requestValidationMode="2.0"/>
8,在Default.aspx页面中添加<asp:TextBox ID="txtcontent" runat="server" TextMode="MultiLine" Height="503px" Width="100%" class="ckeditor" ></asp:TextBox>
<script type="text/javascript">
CKEDITOR.replace('<%= txtcontent.ClientID %>', { skin: 'kama' });
</script>(用ckfinder文件下skins文件下kama文件下的,skin.js,样式)