PHP file lookup program. After a path is entered, all the files and folders under the directory will be traversed, and each file under the folder can be found recursively, and then matched with the entered keyword through the file name, you can find
PHP file lookup program. After a path is entered, all the files and folders under the directory will be traversed, and each file under the folder can be found recursively, and then matched with the entered keyword through the file name, you can find
For local systems, we can use the search provided by windows for search. However, for online systems, such as searching for files in the ftp space, this program is very useful.
PHP file finder source code:
File search for php) <? Php/** Note: Case Sensitive ** by: */if (! Empty ($ _ POST ['path']) &! Empty ($ _ POST ['key']) {echo "in path ". $ _ POST ['path']. "/In Search ". $ _ POST ['key']. the result is:
"; $ File_num = $ dir_num = 0; $ r_file_num = $ r_dir_num = 0; $ findFile = $ _ POST ['key']; function delDirAndFile ($ dirName) {if ($ handle = @ opendir ("$ dirName") {while (false! ==( $ Item = readdir ($ handle) {if ($ item! = "." & $ Item! = ".. ") {If (is_dir (" $ dirName/$ item ") {delDirAndFile (" $ dirName/$ item ");} else {$ GLOBALS ['file _ num'] ++; if (strstr ($ item, $ GLOBALS ['findfile']) {echo"
$ DirName/$ item
\ N "; $ GLOBALS ['r _ file_num '] ++ ;}}} closedir ($ handle); $ GLOBALS ['dir _ num'] ++; if (strstr ($ dirName, $ GLOBALS ['findfile']) {$ loop = explode ($ GLOBALS ['findfile'], $ dirName ); $ countArr = count ($ loop)-1; if (empty ($ loop [$ countArr]) {echo"
$ DirName
\ N "; $ GLOBALS ['r _ dir_num '] ++ ;}}} else {die (" this path is not available! ") ;}} DelDirAndFile ($ _ POST ['path']); echo" ". $ File_num." files, Folders ". $ dir_num." are found in this query.
"; Echo" A total of ". $ r_file_num." files and folders ". $ r_dir_num." matching results
";}?>
The above is the PHP file finder program. You can search for local files for easy operations. I hope it will be helpful for your learning.