我有一些接受富文本格式的页面。我只是使用ckeditor控件。它加载得很好。但无法显示用于上传图片的图片浏览器标签。这是我的html标记:
<script type="text/javascript">
$(function () {
CKEDITOR.replace('<%=CKEditor1.ClientID %>', { filebrowserImageUploadUrl: 'Upload.ashx' });
});
</script>
<tr>
<td style="width: 20%">Template Body
</td>
<td>
<CKEditor:CKEditorControl ID="CKEditor1" runat="server" ValidationGroup="AddNewTemplate" PasteFromWordRemoveFontStyles="False"></CKEditor:CKEditorControl>
<asp:CustomValidator ID="CustomValidator2" runat="server"
ErrorMessage="Template body is required."
OnServerValidate="CustomValidator2_ServerValidate"
ValidationGroup="AddNewTemplate" ForeColor="Red"></asp:CustomValidator>
</td>
</tr>
这是我上传的用于图像上传的ashx文件。
<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.Configuration;
using System.IO;
public class Upload : IHttpHandler {
public void ProcessRequest (HttpContext context) {
HttpPostedFile uploads = context.Request.Files["upload"];
string CKEditorFuncNum = context.Request["CKEditorFuncNum"];
string file = DateTime.Now.ToString("ddMMyyyy_HHmmss") + Path.GetExtension(uploads.FileName);
uploads.SaveAs(context.Server.MapPath(".") + "\\EmailImages\\" + file);
//provide direct URL here
string url = "/EmailImages/" + file;
context.Response.Write("<script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\");</script>");
context.Response.End();
}
public bool IsReusable {
get { return false; }
}
}