如何為fckeditor文字編輯器增加圖片刪除功能

來源:互聯網
上載者:User

 

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");  %>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.