We often encounter the creation of files directory, file (folder) editing operations, today to introduce you a PHP file directory operation class, you can set up directories, delete directories, create files, delete files, move folders, copy folders and other functions you can operate.
First download the php file directory operation class library that we need to use in this lesson: http://www.php.cn/xiazai/leiku/544
After the download, find the PHP class files we need, unzip to our local directory, create a new PHP file!
Once this is done, we will invoke this class in the new PHP file, and instantiate the class:
<?phpinclude_once "caozuo1.php"; Introduce class file $obj = new Fileutil; Instantiate class $obj->createdir (' A/1/2/3 '); Test build folder to build a A/1/2/3 folder $obj->createfile (' B/1/2/3 '); The test build file is built under the b/1/2/folder with a 3 file $obj->createfile (' B/1/2/3.exe '); Test the build file under the b/1/2/folder to build a 3.exe file $obj->copydir (' B ', ' d/e '); Test the Copy folder to create a d/e folder, copy the contents of the B folder into the $obj->copyfile (' B/1/2/3.exe ', ' b/b/3.exe '); Test the copy file to create a b/b folder and copy the 3.exe file in the B/1/2 folder into $obj->movedir (' A ', ' b/c '); Test the Mobile folder to create a b/c folder, and move the contents of the A folder into, and delete the A folder $obj->movefile (' B/1/2/3.exe ', ' b/d/3.exe '); Test the move file to create a b/d folder and move the 3.exe in the B/1/2 to $obj->unlinkfile (' B/d/3.exe '); Test Delete file Delete b/d/3.exe file $obj->unlinkdir (' d '); Test Delete folder Delete D folder?>
Note: This run results page will be blank:
But in our local I can find that the file directory has been created, such as: