My project files are located on remote server in the folder. I access a file in this folder in this way:
http://www.example.com/searchtest.html
This opens a page with Input Box where user types keywords to search. The search script is a .php file located in the root itself. The script has to search for .html files with the name similar to the keywords entered. These .html files are also located in the same root folder where all .php files reside.
My application is running well when I work on local machine and is able to search well, but when I hosted it on my site, it gives error:
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
It is giving error on a line where I am trying to access files in my directory. Below is my code snippet. And yes, I am the administrator and I have all privileges on my site.
$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;
}
}
It gives error probably in the "opendir" function.
I also want to know whether the $dirName holds correct path or not. It must hold the same path from where the correct script is run.