Home >Backend Development >PHP Tutorial >[Original] PHP+ajax implements simulated Win file management system 8_PHP tutorial

[Original] PHP+ajax implements simulated Win file management system 8_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:59:51785browse

I have been quite busy during this period, so I took some time off to finish it. Now I will continue to talk about the js.js file renaming function

function edit(e,path){


var text=e.innerHTML;


var eT=document.createElement("input");//The file name is rewritten according to the user's click


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)};

}

};

}

The above is DOM+JS to complete and operate the file.

function CreateAjax(){//I won’t say much about this function, it has been discussed many times.

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('Sorry, the browser you are using does not support AJAX!'); return false;}


}


function Re_name(o_name,n_name,e){ //Renamed here.

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

if(name.match(/^w{1,255}.w{1,8}$/i)){//Use regular rules to determine the legality of the file name.

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

 

e.innerHTML=name;

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

Sorry, the file extension cannot be modified...
";

                                   

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('illegal operation');


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); //Send to rename.php

}



http://www.bkjia.com/PHPjc/631848.html

truehttp: //www.bkjia.com/PHPjc/631848.htmlTechArticleI’ve been quite busy during this period, so I took some time to finish it. I’ll continue to talk about it today. js.js file renaming function function edit(e,path){ var text=e.innerHTML; var eT=docume...
Statement:
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