请教当使用FCKEDITOR上传图片后,比如上传了两个图片,怎么在FCKEDITOR外的
<select>
<option>/UserFiles/image/01.jpg</option>
<option>/UserFiles/image/02.jpg</option>
< /select>
中取得刚才上传图片的路径?
多谢了!
<select>
<option>/UserFiles/image/01.jpg</option>
<option>/UserFiles/image/02.jpg</option>
< /select>
中取得刚才上传图片的路径?
多谢了!
MatchCollection matchs = Regex.Matches(fckStr, @ " <img\s[^> ]*src=([ " " ']*)(? <src> [^ ' " "]*)\1[^> ]*> ", RegexOptions.IgnoreCase);
foreach (Match m in matchs) {
Response.Write(m.Groups[ "src "].Value+ " <br> ");
}
我自己写的/// <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;
}
[email protected]
/// 取得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就可以了。。