请教当使用FCKEDITOR上传图片后,比如上传了两个图片,怎么在FCKEDITOR外的
<select>
  <option>/UserFiles/image/01.jpg</option>   
  <option>/UserFiles/image/02.jpg</option>
< /select>
中取得刚才上传图片的路径?
多谢了!

解决方案 »

  1.   

    string   fckStr   =   FCKeditor1.Value; 
                    MatchCollection   matchs   =   Regex.Matches(fckStr,   @ " <img\s[^> ]*src=([ " " ']*)(? <src> [^ ' " "]*)\1[^> ]*> ",   RegexOptions.IgnoreCase); 
                    foreach   (Match   m   in   matchs)   { 
                            Response.Write(m.Groups[ "src "].Value+ " <br> "); 
                    } 
      

  2.   

    应该是这样的 需要把m.Groups[ "src "].Value放在隐藏值里面 以后都可以读取到了。
      

  3.   

    是用ajax和 setInterval()循环读取吗,每隔一秒读取一次怎么样?
      

  4.   

    没有好办法的,人生如梦说的办法只是从fckeditor编辑器的内容中获取img标签所指向的图片路径,这些图片不一定都是刚刚上传的,也有可能是引用的别的地方的图片,另外通过fckeditor上传图片后,不一定非得把图片插入到编辑器中,也可能不想用了从编辑器中删除了,但图片还是上传到服务器上了。
      

  5.   

    引用别的地方的图片的情况先不考虑,是不是得用是用ajax和 setInterval()循环读取将最新的img标签加到select下拉框中,每隔一秒读取一次怎么样,这种方式可行吗?
      

  6.   

    就是这样。
    我自己写的/// <summary>
            /// 取得FCKeditor中的图片路径数组(参数表示为上传图片文件夹的名称)
            /// </summary>
            /// <returns></returns>
            public static ArrayList getpicpath(FredCK.FCKeditorV2.FCKeditor FCKeditor1, string filepath)
            {
                string ms = "";
                ArrayList imgList = new ArrayList();
                // string ss = "/(\\w*.(gif|jpg|bmp|png))";
                string imageZz = @"<img[^src]*src=""[^http\://]*(?<picurl>[^""]*?)""";
                Regex re = new Regex(imageZz);
                MatchCollection mc = re.Matches(FCKeditor1.Value);
                foreach (Match m in mc)
                {
                    ms += m.Groups[1].Value + ",";
                }            if (ms.Length > 0)
                {
                    ms = ms.Substring(0, ms.Length - 1);
                    string[] msArry = ms.Split(',');
                    for (int i = 0; i < msArry.Length; i++)
                    {
                        imgList.Add(msArry[i].Substring(msArry[i].IndexOf(filepath, 0)));
                    }
                }
                return imgList;
            }
      

  7.   

    可以分享下代码吗?
    [email protected]  
      

  8.   

    您是完全用后台处理还是用ajax,可否看看完整的代码,谢谢
      

  9.   

    /// <summary>
            /// 取得FCK,HTML中所有图片的 URL。
            /// </summary>
            /// <param name="sHtmlText">HTML代码</param>
            /// <returns>图片的URL列表</returns>
            public static string[] GetHtmlImageUrlList(string sHtmlText)
            {
                // 定义正则表达式用来匹配 img 标签
                Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);            // 搜索匹配的字符串
                MatchCollection matches = regImg.Matches(sHtmlText);            int i = 0;
                string[] sUrlList = new string[matches.Count];            // 取得匹配项列表
                foreach (Match match in matches)
                    sUrlList[i++] = match.Groups["imgUrl"].Value;            return sUrlList;
            }把这个数组绑定到dropdownlist中。至于取得fck的代码直接FCKeditor1.Value就可以了。。