提取CuteEditor编辑器中的图片地址,并将远程图片保存到本地

来源:互联网 发布:淘宝如何优化排名 编辑:程序博客网 时间:2024/05/17 09:28

有个属性的AutoConfigure  
  选择其中的,按钮就会不同,还可以自己定义

本篇文章来自<A href='http://www.soidc.net'>IDC专家网</a> 原文链接:http://www.soidc.net/discuss/5/060815/10/428252_1.html


要自定义的话,在文件夹CuteSoft_ClientCuteEditorConfigurationAutoConfigure  
  下面,修改其中一个,在选择它就好了  
  比如改Minimal.config  
  <item   name="Editing"   value="False"   />  
  <item   name="Format"   value="False"   />  
  <item   name="Insert"   value="False"   />  
  <item   name="InsertAdvanced"   value="False"   />  
  <item   name="InsertFiles"   value="False"   />  
  <item   name="InsertForms"   value="False"   />  
  <item   name="Relative"   value="False"   />  
  <item   name="Tags"   value="False"   />  
  <item   name="Verbs"   value="False"   />  
  去掉item某项,就不显示了

本篇文章来自<A href='http://www.soidc.net'>IDC专家网</a> 原文链接:http://www.soidc.net/discuss/5/060815/10/428252_1.html

 

 

            string str = "<img  height=/"325/" width=/"500/" src=/"/image/B011627669461283B6A55B8611153813.jpg/" />";
            string str = "<input type=/"image/" height=/"325/" width=/"500/" src=/"FCKeditor/editor/filemanager/connectors/aspx/userfiles/image/B011627669461283B6A55B8611153813.jpg/" />";
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"<input[^>].*?src=""(?<src>[^""].*)""[^>].*?>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"<img  [^>].*?src=""(?<src>[^""].*)""[^>].*?>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串
            System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串
            for (int i = 0; i < m.Count; i++)
            {
                Response.Write(m[i].Groups["src"].ToString() + "<br>");
            }

            string str = "这里是你从从数据库里读出的内容,包括很多图片的html标签(如 <img )";
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@" <img[^>].*?src=""(? <src>[^""].*)""[^>].*?>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串
            for (int i = 0; i < m.Count; i++)
            {
                Response.Write(m[i].Groups["src"].ToString()+" <br>");
            }


            //提取CuteEditor编辑器中的图片地址,并将远程图片保存到本地
Regex    re   =   new    Regex(@"src/s*=/s*(?:([""'])(?<src>[^""']+)/1|(?<src>[^/s>]+))",    RegexOptions.IgnoreCase   |    RegexOptions.Singleline);  
             MatchCollection    mc   =    re.Matches(this.Editor1.XHTML.ToString());  
            foreach    (Match    m   in    mc)  
            {  
                string url=m.Groups["src"].Value;
                string filepath=url;
                if(url.Substring(0,7).ToLower()=="http://")
                {
                    string KuoZhangMing="."+url.Substring(url.LastIndexOf(".")+1);
                    string path = HttpContext.Current.Server.MapPath(@"/MLXZ/Uploads/Download/");
                    string filename=DateTime.Now.ToString("yyyyMMddHHmmss")+KuoZhangMing;
                     path=path+filename;
                     mailto:filepath=@%22/MLXZ/Uploads/Download/%22+filename;
                     WebClient myWebClient = new WebClient();
                     myWebClient.DownloadFile(url,path);
                    this.Editor1.Text=this.Editor1.XHTML.ToString().Replace(url,filepath);
                 }
                 Pic.Items.Add(new    ListItem(filepath,filepath));
             }

 

 


string str = "这里是你从从数据库里读出的内容,包括很多图片的html标签(如 <img )"
string[] stes=new string []{};//一个数组
System.Text.RegularExpressions.Regex  reg=new  System.Text.RegularExpressions.Regex(@" <img[^>].*?src=""(? <src>[^""].*)""[^>].*?>",System.Text.RegularExpressions.RegexOptions.IgnoreCase); 
            System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串
            for (int i = 0; i < m.Count; i++)
            {
                      stes[i]= m[i].Groups["src"].ToString();

            }

this.DropDownList1.DataSource = stes;
        this.DropDownList1.DataBind();


List <string> swd=new List <string>();
for (int i = 0; i < m.Count; i++)
            {
                   
            swd.add( m[i].Groups["src"].ToString());
            }

 

原创粉丝点击