一个简单的检索本地文件,可以拿来作为发布标准规范,用来查询还是很方便的。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/wap.css" rel="stylesheet" type="text/css" />
<title>标准规范查询</title>
</head>
<body>
<form action="" method="post">
<div id="create_form" align='center'>
<p> (注:区分大小写不支持多关键词,建议只输入标准序号或名称)</p>
<p>请输入关键字:<input type="text" name="key" /><input type="submit" name="sub" value=" 查 询 " /></p>
</div>
</form>
<?php
if(!empty($_POST['key'])){
$file_num = $dir_num = 0;
$r_file_num = $r_dir_num= 0;
$findFile = $_POST['key'];
echo "<table>";
echo "<tr class=\"tt\"><td>序号</td><td>文件名</td><td>大小</td></tr>";
function delDirAndFile( $dirName ){
static $num =0;
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'])){
$num++;
$subfile =str_replace('D:\wwwroot\stds','http://192.168.0.1/stds', $dirName );
$Size= filesize("$dirName/$item");
$Size= number_format($Size/1000000, 2);
//$subfile =str_replace('.','-',$subfile);
echo " <tr><td align='center'>$num</td><td><a target=\"_blank\" href=\"$subfile/$item \">$item</a></td><td>$Size MB</td></tr>\n";
$GLOBALS['r_file_num']++;
}
}
}
}
closedir( $handle );
}
}
delDirAndFile('D:\\wwwroot\\stds');
echo "</table><div align='center'>从 $file_num 个文件中,查询到".$r_file_num."个文件,下载请直接右键另存。</div>";
}
?>
</body>
</html>