【发布时间】:2017-11-25 08:10:19
【问题描述】:
我有一个 PHP 代码,允许用户从指定的目的地选择 PDF 文件。我需要允许用户输入一个字符串作为用户输入,并使系统读取所有 pdfs 文件的内容,如果字符串存在于任何 PDF 文件中,则显示文件名。
到目前为止,我只能选择 PDF 文件。
代码:
<?php
//path to directory
$directory = $_SERVER['DOCUMENT_ROOT']."/testwebsite\OSWebProject/";
$pdfs= glob($directory. "*.pdf") or DIE("Unable to open $directory");;
if(isset($_POST["search"]))
{
$NAME =$_POST['name'];
echo $NAME ;
foreach($pdfs as $pdfname ){
echo $pdfname;
}
}
?>
<html>
<head>
</head>
<body>
<form action="test.php" method="post">
<p>enter your string <input type ="text" id = "idName" name="name" /></p>
<p><input type ="Submit" name ="search" value= "Search" /></p>
</form>
</body>
</html>
【问题讨论】:
-
听起来像是
pdfgrep的工作。