zoukankan      html  css  js  c++  java
  • 如何为fckeditor文本编辑器增加图片删除功能

    1、在\fckeditor\editor\filemanager\browser\default文件夹中找到frmresourceslist.html文件,将其代码改为:

    oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
      
     
       var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');   return false;">' ;     
      var sIcon = oIcons.GetIcon( fileName ) ;   
      return '<tr>' +   '<td width="16">' +      sLink +      '<img alt="" src="images/icons/' +   sIcon +
       '.gif" width="16" height="16"  border="0"> <\/a>' +  
           '<\/td><td>&nbsp;' +      sLink +      fileName +      '<\/a> <a href="#" onclick="deleteFile(\'' + ProtectPath( fileUrl ) + '\');" style="color: #FF9933;"> 删除 <\/a>' +     '<\/td><td align="right" nowrap>&nbsp;' +      fileSize +      ' KB' +    '<\/td><\/tr>' ;
         }

    2、在该文件的js中增加如下代码:

    //产生不重复的随机数
       var rn = Math.ceil(Math.random() * 1000000); 
       var rnch = rn;
        function rndnum()
            while (rn == rnch) rn = Math.ceil(Math.random() * 1000000);  
           rnch = rn;    
         return rn;
         
          // 删除文件
         function deleteFile(file)
              var xml = new ActiveXObject("MSXML2.XMLHTTP");   
            xml.open("get", "FCKdel_file.aspx?filePath=" + escape(file) + "&UD=" + rndnum(), false);   
           xml.send();    
            Refresh();  
            switch (xml.responseText.substring(0,1))  
                       case "1": alert("文件删除成功!");
            break;   
                  case "0": alert("文件删除失败!请检查文件是否存在!");
            break;    
                 case "2": alert("您不是系统管理员,无权进行操作!");
               break;    
                   default: alert("未知错误!");
                 break;   
                 
               }

    3、在同一个目录(指frmresourceslist.html所在目录)增加一个文件:FCKdel_file.aspx,代码如下:

    <%@ Page Language="C#" %> 
     <%    
     //if 判断条件中,第一个条件是为了防止没有权限的用户删除文件,可以根据需要修改.   
      if ( Session["adminusername"] != null) 
             
      if (Request.QueryString["UD"] != null)     
                  
     try          
                      System.IO.File.Delete(Server.MapPath(Request.QueryString["filePath"].Trim()));                  Response.Write("1");    
               
             catch     
                           Response.Write("0");                
          
          else Response.Write("0");       
      else Response.Write("2");  %>

  • 相关阅读:
    bzoj-2748 2748: [HAOI2012]音量调节(dp)
    bzoj-2338 2338: [HNOI2011]数矩形(计算几何)
    bzoj-3444 3444: 最后的晚餐(组合数学)
    codeforces 709E E. Centroids(树形dp)
    codeforces 709D D. Recover the String(构造)
    codeforces 709C C. Letters Cyclic Shift(贪心)
    codeforces 709B B. Checkpoints(水题)
    codeforces 709A A. Juicer(水题)
    Repeat Number
    hdu 1003 Max Sum (动态规划)
  • 原文地址:https://www.cnblogs.com/mxh691/p/1510032.html
Copyright © 2011-2022 走看看