日期:2014-05-17  浏览次数:20461 次

fckeditor2.6上传中文图片名后被编码的问题
比如,我上传一张名为“服务器的问题.jpg",上传成功后,确实在磁盘上是原来的名字。
但在编辑器看到的源代码居然是:%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%97%AE%E9%A2%98.jpg

我想编辑器里通过枚举第一张图片生成缩略图,结果提示找不到文件,当然找不到了。
如何防止被它编码?

代码如下:
       //取得FCK,HTML中所有图片的 URL。
        private static string[] GetHtmlImageUrlList(string sHtmlText)
        {
            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;
        }
        /// <summary>
        /// 提取第一张图片做为缩略图
        /// </summary>
        /// <returns></returns>
        private string GetFirstImagePath()
        {
            string[] pics = new string[0];
            pics = GetHtmlImageUrlList(fck.Value);
            string sFileName;
            if (pics.Length > 0)
            {
                //原图
                //return pics[0];
                //原始图
                string webFilePath = Server.MapPath("~" + pics[0]);