我的项目文件位于文件夹中的远程服务器上。我访问一个文件此文件夹中以这样的方式PHP目录处理
http://www.example.com/searchtest.html
这将打开一个页面,输入框,用户键入关键字进行搜索。搜索脚本是一个位于根本身的.php文件。该脚本必须搜索与输入的关键字类似的名称的.html文件。这些.html文件也位于所有.php文件所在的同一个根文件夹中。
我的应用程序运行良好,当我在本地机器上工作,是能够搜索很好,但是当我主持它在我的网站,它提供了错误:
Warning: file_get_contents(//.rnd) [function.file-get-contents]: failed to open stream: Permission denied in /home/myServer/public_html/example/search1.php on line 40 .rnd
这是给上线,其中的错误我正在尝试访问我的目录中的文件。以下是我的代码片段。是的,我是管理员,我拥有我网站的所有权限。
$matchingFiles = array();
$dirName = "\\";
$dh = opendir($dirName);
while( ($file = readdir($dh)) !== false)
{
$fullPath = $dirName . "/" . $file;
if(is_dir($fullPath)) continue; // Skip directories
similar_text($lcSearch,strtolower($file),$percentSimilar);
if($percentSimilar >= $percentMatch)
{
$matchingFiles[] = $fullPath;
}
}
它可能在“opendir”函数中给出错误。
我也想知道$dirName
是否保持正确的路径。它必须保持正确脚本运行的路径。