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.
Effect:
PHP file finder source code:
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> file search for php </title>
</Head>
<Body>
<Form action = "" method = "post">
<P> file search (Note: Case Sensitive) </p>
<P> path: <input type = "text" name = "path"/> </p>
<P> Search: <input type = "text" name = "key"/> </p>
<P> <input type = "submit" name = "sub" value = "start"/> </p>
</Form>
</Body>
</Html>
<? Php
/*
* Note: Case Sensitive
* By: http://www.jb51.net
*/
If (! Empty ($ _ POST ['path']) &! Empty ($ _ POST ['key']) {
Echo "in path ". $ _ POST ['path']. "/In Search ". $ _ POST ['key']. "Result: $ 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 "<span> <B> $ dirName/$ item </B> </span> <br/> \ 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 "<span style = 'color: #297C79; '> <B> $ dirName </B> </span> <br/> \ n ";
$ GLOBALS ['r _ dir_num '] ++;
}
}
} Else {
Die ("this path is not available! ");
}
}
DelDirAndFile ($ _ POST ['path']);
Echo "Echo "}
?>