Home > Backend Development > PHP Tutorial > In which folder should the psp3000 game be placed? How to traverse all files in the folder, edit and delete them using PHP

In which folder should the psp3000 game be placed? How to traverse all files in the folder, edit and delete them using PHP

WBOY
Release: 2016-07-29 08:41:40
Original
7079 people have browsed it

Copy the code The code is as follows:


/*
Traverse folders; Function: (a) Deleteable files (b) Editable text, web page files (c) Deleteable folders, provided the folder is empty (d) Yes Create files, folders, and modify folder names;
lost63.com original, please indicate the source for reprinting. Communication QQ: 35501547
*/
$path=$DOCUMENT_ROOT;
$path=str_replace("/","\" ,$path);
//Specify the folder
$path=$path."\";
if($_GET['folder'])
{
$path.=$_GET['folder']."\ ";
}
//The path of this page will be used when returning below;
$url=$_SERVER['PHP_SELF'];
//If it is a folder, a link will be added;
function folder($path ,$str)
{
if(filetype($path.$str)=="dir")
{
return "$str";
}else{
return $str;
}
}
switch($_GET['action'])
{
case "del";
if ($_GET['type']=="file")
{
unlink($_GET['path']);
}else{
rmdir($_GET['path']);
}
echo "< ;script type="text/javascript">alert('Congratulations, deletion successful!');location.href="".$url."";";
break;
case "edit" ;
if($_GET['type']=="file")
{
$file=fopen($_GET['path'],"r");
while(!feof($file))
{
$result.=fgets($file,9999);
}
fclose($file);
echo '














>> Edit file > Return
->File name:'.$_GET['path'].'


';
}else{
echo '











>>< ;strong> New file > Return
->Folder rename:


';
}
break;
case "editsave";
$file=fopen($_GET['path'],"w");
fwrite($file,$_POST['textarea']);
fclose($file);
echo "";
break;
case "addfile";
echo '














>> 新建文件 > 返回
->文件名:


';
break;
case "filesave";
//包含点则建立文件,否则建立文件夹
if(strpos($_POST['filename'],"."))
{
$file=fopen($_POST['filename'],"w");
fwrite($file,$_POST['textarea']);
fclose($file);
}else{
//文件夹若存在则退出,不存在则建立!
if(file_exists($_POST['filename']))
{
exit;
}else{
mkdir($_POST['filename']);
}
}
echo "";
break;
case "dir_rename";
rename($_GET['path'],$_POST['filename']);
echo "";
break;
default:
$s=explode("n",trim(`dir/b/o:gn $path`));
echo '








';
foreach($s as $value)
{
echo '





';
}
echo "
>> 文件管理 > 建立文件 > 返回
文件/文件夹 文件属性 文件大小 操作
'.folder($path,$value).' '.filetype($path.$value).' '.round(filesize($path.$value)/1024).'kb 编辑 | '.$value.'');">删除
";
break;
}
?>

以上就介绍了psp3000游戏放在哪个文件夹 php实现的遍历文件夹下所有文件,编辑删除,包括了psp3000游戏放在哪个文件夹方面的内容,希望对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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template