文件目录如下1、当我点击GV控件的编辑按钮跳到EditNoticeList.aspx,EditNoticeList.aspx页面里头有一个标题和一个kindEditor编辑器,并且提取数据库的内容出来,如下图:数据库图片的路径是:
<img src="upload/23831865_720130306233042.jpg" alt="" border="0" />
2、编辑完成后,应该可以在前台的NoticeList.aspx查看文字和图片,但是就是因为图片Src路径的问题显示不出来
3、我想问的是,如何使得我在编辑器编辑内容包含的图片既可以在编辑器显示也可以在前台显示,这路径或文件夹应该放在哪里呢?

解决方案 »

  1.   

    上传类如下
    <%@ WebHandler Language="C#" Class="upload" %>
    using System;
    using System.Web;
    using System.IO;
    using System.Text;public class upload : IHttpHandler
    {    public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            // 下面这句是最重要的,取得HttpPostedFile对象后就可以调用他的SaveAs方法了  
            HttpPostedFile imgFile = HttpContext.Current.Request.Files["imgFile"];
            //获取文件名
            string fileName =Convert.ToString(new FileInfo(imgFile.FileName));
            // 取文件后缀名
            string houzui = new FileInfo(imgFile.FileName).Extension;
            //获取.位置
            int dian = fileName.LastIndexOf(".");//获取文件点的索引位置
            //创建新的名字,防止重名
            string newname = fileName.Substring(0, dian) + DateTime.Now.ToString("yyyyMMddHHmmss") + houzui;
            //获取uploas.ashx所在文件物理路径
            string path = context.Server.MapPath("../");
            // 保存文件到根目录下的upload目录中
            string savePath = path+"upload\\" + newname;
            imgFile.SaveAs(savePath);        // 插入图片到kindeditor中
            string id = context.Request["id"];
            string file_url = "upload/" + newname;
            string imgTitle = context.Request["imgTitle"];
            string imgWidth = context.Request["imgWidth"];
            string imgHeight = context.Request["imgHeight"];
            string imgBorder = context.Request["imgBorder"];
            StringBuilder sb = new StringBuilder();
            sb.Append("<html>");
            sb.Append("<head>");
            sb.Append("<title>Insert Image</title>");
            sb.Append("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">");
            sb.Append("</head>");
            sb.Append("<body>");
            sb.Append("<script type=\"text/javascript\">parent.KE.plugin[\"image\"].insert(\"" + id + "\", \"" + file_url + "\",\"" + imgTitle + "\",\"" + imgWidth + "\",\"" + imgHeight + "\",\"" + imgBorder + "\");</script>");
            sb.Append("</body>");
            sb.Append("</html>");
            
            context.Response.Write(sb.ToString());    }    public bool IsReusable
        {
            get
            {
                return false;
            }
        }}
      

  2.   

    kindeditor/asp.net/upload_json.ashx应该有这么一个文件
    里面可以修改一些上传信息的设置
    文件的大致内容如LS
    LZ只需修改saveUrl的路径即可 
      

  3.   

    你的图片路径是upload/23831865_720130306233042.jpg,确保根目录下有upload的文件
    修改file_manager_json.ashx修改图片上传路径String rootPath = "../upload/"; 把路径调整到根目录,
      

  4.   

    我现在的问题是如果在编辑器中显示的话,UI就不能显示,如果能在UI显示的话,编辑器就不能显示
      

  5.   

    编辑器中路径是:upload/***.jpg才能显示,UI中路径是:Admin/upload/***.jpg才能显示,怎么改呢