My project files are located on remote server in the folder. I access a file in this folder in this way:
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
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
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.
Assuming you did not change the $dirName assignment to omit server detail on a public posting, you should be setting that to the path to search. Since your use is pretty static, I'd suggest using the full path to the directory to open, e.g.
$dirName = '/home/myServer/public_html';
And of course make sure the permissions to all files it will search are compatible with the user your server is running as.