PHP implementation of Traverse folder under All files, edit delete _php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
/*
Traverse the folder; Function: (a) can delete the file (b) editable text, Web page file (c) can delete the folder, if the folder is empty (d) can establish files, folders, modify the folder name;
lost63.com original, reproduced please indicate the source. AC qq:35501547
*/
$path = $DOCUMENT _root;
$path =str_replace ("/", "\ \", $path);
Specify folder
$path = $path. " \\";
if ($_get[' folder ')
{
$path. =$_get[' folder ']. " \\";
}
This page path, will be used when the following return;
$url =$_server[' php_self '];
If it is a folder, the 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 "";
Break
Case "edit";
if ($_get[' type ']== "file")
{
$file =fopen ($_get[' path '], "R");
while (!feof ($file))
{
$result. =fgets ($file, 9999);
}
Fclose ($file);
Echo ';
}else{
Echo ';
}
Break
Case "Editsave";
$file =fopen ($_get[' path '], "w");
Fwrite ($file, $_post[' textarea ');
Fclose ($file);
echo "";
Break
Case "AddFile";
Echo ';
Break
Case "FileSave";
Include point to create file or create folder
if (Strpos ($_post[' filename '], "."))
{
$file =fopen ($_post[' filename '], "w");
Fwrite ($file, $_post[' textarea ');
Fclose ($file);
}else{
If the folder exists then exits, does not exist then establishes!
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 "
>> file Management > build file > Return
Files/Folders File properties File size Operation
'. folder ($path, $value). ' '. FileType ($path. $value). ' '. Round (FileSize ($path. $value)/1024). ' Kb Edit | '. $value. ' \');" > Delete
";
Break
}
?>

http://www.bkjia.com/PHPjc/321015.html www.bkjia.com true http://www.bkjia.com/PHPjc/321015.html techarticle Copy the code as follows:? PHP/* Traverse folder; function: (a) can delete file (b) editable text, Web page file (c) can delete folder, if the folder is empty (d) can establish file, text ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.