2013-05-04 36 views
1

我使用CKEditor进行我的asp.net C#项目。 如何为编辑器启用图片上传标签。我读了一些文章,但没有一篇有用。其中一些用于php的地方。我想要的是asp.net。 感谢您的帮助。在asp.net中启用CKEditor的图片上传

+0

已回答:http://stackoverflow.com/questions/2115302/ckeditor-image-upload-filebrowseruploadurl – IrishChieftain 2013-05-04 19:53:59

回答

0

终于我能找到解决方案。

我做了两件事来解决我的问题。

首先我编辑了config.ascx文件并将基础url设置为images文件夹。如下图所示:

公共覆盖无效调用setConfig() {

// The base URL used to reach files in CKFinder through the browser. 
    BaseUrl = "~/images/"; 
    // The phisical directory in the server where the file will end up. If 
    // blank, CKFinder attempts to resolve BaseUrl. 
    BaseDir = ""; 
} 

,我得是,我的网页是在管理文件夹,我把CKEditor的和ckfinder文件夹在我的网站的根目录下的错误。

通过将这些文件放在管理文件夹中解决问题。

谢谢。

4

我喜欢http://www.codedigest.com/Articles/ASPNET/423_Upload_Images_and_Integrate_with_CKeditor_in_AspNet.aspx letutorial for使用filebrowserImageUploadUrl属性与我们自己的文件上传器的实现。但上传的底部没有出现,也没有发生任何事情。我的代码是在这里:

<head runat="server"> 

    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 
    <script src="ckeditor/ckeditor.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
     $(function() { 
      CKEDITOR.replace('<%=CKEditor1.ClientID %>', { filebrowserImageUploadUrl: '/Upload.ashx' }); 
     }); 
</script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
    <CKEditor:CKEditorControl ID="CKEditor1" BasePath="~/ckeditor/" runat="server" Width="600px" Height="200px"></CKEditor:CKEditorControl> 
    </div> 
    </form> 
</body> 
</html> 

和ashx的文件:

<%@ WebHandler Language="C#" Class="Upload" %> 

using System; 
using System.Web; 

public class Upload : IHttpHandler { 

    public void ProcessRequest (HttpContext context) { 
     HttpPostedFile uploads = context.Request.Files["upload"]; 
     string CKEditorFuncNum = context.Request["CKEditorFuncNum"]; 
     string file = System.IO.Path.GetFileName(uploads.FileName); 
     uploads.SaveAs(context.Server.MapPath(".") + "\\Images\\" + file); 
     string url = "/Images/" + file; 
     context.Response.Write("<script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\");</script>"); 
     context.Response.End();    
    } 

    public bool IsReusable { 
     get { 
      return false; 
     } 
    } 

} 
1

如果你只是想使隐藏的选项卡只在脚本文件夹

CKEDITOR.config.extraPlugins = 'imageuploader'; 

增加但会有在控制台中的错误,因为你必须定义链接,这将是行动上传文件/图像,像

filebrowserImageBrowseUrl: 'YourController/YourAction',    
filebrowserImageUploadUrl: 'YourController/YourAction' 
相关问题