在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>文件查找(file search)</title> </head> <body> <form action="" method="post"> <p> 文件查找(注:区分大小写)</p> <!--<p>路径:<input type="text" name="path" /></p> 从哪个文件夹搜索 --> <p>查找文件:<input type="text" name="key" /></p> <p><input type="submit" name="sub" value="开 始" autocomplete="off"/></p> </form> </body> </html> <?php /* * 注:区分大小写 * if(!empty($_POST['path'])&&!empty($_POST['key'])){ echo "在路径 ".$_POST['path']."/ 中查找 ".$_POST['key']." 的结果为:<hr/>"; 自定义文件夹位置 */ if((uploads)&&!empty($_POST['key'])){ echo "在路径 .uploads./ 中查找 ".$_POST['key']." 的结果为:<hr/>"; $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("没有此路径!"); } } delDirAndFile(uploads); echo '符合结果的共<font style="color:#FF0000;">'.$r_file_num.'</font>个文件,文件夹<font style="color:#FF0000;">'.$r_file_num.'</font>个'; echo "<hr/>本次共搜索了".$file_num."个文件,文件夹".$dir_num."个<br/>"; } ?>
|
2022-08-15
2022-08-17
2022-11-06
2022-08-17
2022-07-18
请发表评论