Home > php教程 > php手册 > [原创]php+ajax实现模拟Win文件管理系统八

[原创]php+ajax实现模拟Win文件管理系统八

WBOY
Release: 2016-06-13 09:59:23
Original
1174 people have browsed it

这段时间比较忙所以段了一段时间,今天抽点时间把它写完,下面我继续讲js.js文件重命名函数

 function edit(e,path){


  var text=e.innerHTML;


  var eT=document.createElement("input");//这里是根据用户单击情况重写文件名


  e.innerHTML="";


  e.appendChild(eT);


 eT.value=text;


  eT.select();


  e.onclick="";


  eT.onblur=function(){        


  CreateAjax();


  if(text == this.value){


    e.innerHTML=this.value;


    e.onclick=function(){edit(this,path)};


    return false;


  }else{  


    e.innerHTML=this.value;


    Re_name(path,this.value,e);   


    e.onclick=function(){edit(this,path)};


  }


  };  


 }

上面了一dom+JS对文件进行完成,操作.

 function CreateAjax(){//这个函数就不多说了,己经讲过多次了.


  try { xmlhttp = new XMLHttpRequest();}


   catch (e){


  try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}


   catch (e2){


  try { xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); }


   catch(e3){ xmlhttp = false; }


  }


  }          


  if( !xmlhttp){alert('对不起,你正在使用的浏览不支持AJAX!');return false;}


  }

function Re_name(o_name,n_name,e){  //这里重命名了.

   var name=o_name.replace(/.*\/(.+)$/i,"$1");

   if(name.match(/^\w{1,255}\.\w{1,8}$/i)){//用正则判断文件名的合法性.

   if(!n_name.match(/^\w{1,250}\.\w{1,8}$/i)){
    
     e.innerHTML=name;

     document.getElementById("t").innerHTML="

对不起,不能修改文件的扩展名...
";
         
     setInterval("func()",3000);  
     
     return false;

   }

   }else if(name.match(/^\w{1,255}$/i)){

    if(!n_name.match(/^\w{1,250}$/i)){

     e.innerHTML=name;
     
     document.getElementById("t").innerHTML="

对不起,不能把文件夹重命名为文件名...
";

     setInterval("func()",3000);
     return false;

   }

   }else{
      alert('非法操作');

     e.innerHTML=name;

     return false;
   }
   var url="rename.php?path="+encodeURI(o_name.replace("/","\/"))+"&nname="+encodeURI(n_name)+"&rd="+Math.random();

   Senddata('GET',url,ReturnValue,null); //了送给rename.php


 }
 

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template