首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

fckeditor2.6上传中文图片名后被编码的有关问题

2013-08-04 
fckeditor2.6上传中文图片名后被编码的问题比如,我上传一张名为“服务器的问题.jpg,上传成功后,确实在磁盘

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]);


                //缩略图
                sFileName = Common.Function.CreateGUID() + Path.GetExtension(webFilePath);
                string webFilePath_s = Server.MapPath("~" + "/upload/fckeditor/image/") + sFileName;

                MakeThumbnail(webFilePath, webFilePath_s, 180, 180, "HW");
                return "/upload/fckeditor/image/" + sFileName;
            }
            else
            {
                return "";
            }
        }

生成缩略图的函数,略
        private void MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)
        {
            System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);

            int towidth = width;
            int toheight = height;
            int x = 0;
[解决办法]
fckeditor现在貌似被拆分成ckeditor和ckfinder两部分,我是用这两部分的,可以实现的哈,楼主你的问题我具体没操作过,支持下啊
[解决办法]

引用:
是不是与htmlencode有关?有试着用htmldecode方法还原,无效


HttpUtility.UrlDecode("%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%97%AE%E9%A2%98.jpg");


这个

热点排行