一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

给fckeditor文本编辑器增加图片删除功能

时间:2011-09-27 编辑:简简单单 来源:一聚教程网


fckeditoreditorfilemanagerbrowserdefault文件夹中找到frmresourceslist.html文件,修改代码如下

oListManager.GetFileRowHtml找到这里,下面代码替换原来的代码

 代码如下 复制代码
oListManager.GetFileRowHtml = function(fileName, fileUrl, fileSize) { 
    // Build the link to view the folder.  
    var sLink = '选择'; 
 
    // Get the file icon.  
    var sIcon = oIcons.GetIcon(fileName); 
 
    return ''   
         ; 

在加个

ajaxdel.js文件

 代码如下 复制代码
//******************************** 图片删除功能 ******************************************  
var req;                    //定义变量,用来创建xmlhttprequest对象   
 
//产生不重复的随机数  
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; 

 
// 删除文件,Ajax开始  
function deleteFile(file) { 
    var url = "/ajaxpic.php?filePath=" + escape(file) + "&UD=" + rndnum();                  //要请求的服务端地址     
    if (window.XMLHttpRequest)                                                                  //非IE浏览器及IE7(7.0及以上版本),用xmlhttprequest对象创建     
    { 
        req = new XMLHttpRequest(); 
    } 
    else if (window.ActiveXObject)                                                              //IE(6.0及以下版本)浏览器用activexobject对象创建,如果用户浏览器禁用了ActiveX,可能会失败.     
    { 
        req = new ActiveXObject("Microsoft.XMLHttp"); 
    } 
     
    if (req)                                                                                    //成功创建xmlhttprequest  
    { 
        req.open("GET", url, true);                                                             //与服务端建立连接(请求方式post或get,地址,true表示异步)     
        req.onreadystatechange = callback;                                                      //指定回调函数     
        req.send(null);                                                                         //发送请求     
    } 

 
function callback() {     
    if(req.responseText ==1 )
 {
  alert('删除成功!');
  Refresh();
 }
 else
 {
  alert('删除失败!');
 }//刷新一下   

ajaxpic.php文件 保存成ajaxpic.php

 代码如下 复制代码

$root = dirname( __FILE__ );
$filePath = isset( $_GET['filePath'] ) ?$_GET['filePath']:'';
if( unlink( $root.$filePath) )
{
 echo '1';
}
else
{
 echo '0';
}
?>

热门栏目