php fopen() problem

Soldato
Joined
1 Feb 2006
Posts
8,188
I have a script which is located outside my document root which is included in a particular page on my website using the include_path directive. In that file I want to use fopen() to read and write to a file. If I put in a path in the document root i.e. "cache/myfile.php" the script complains :

[function.fopen]: failed to
open stream: No such file or directory

Is this due to the fact that the calling script is outside the document root? The script does work if i set the path to 'myfile.php' but not if i add a folder name.

Have had a bit of a google on this but found nothing useful.
 
Yes that was one of the first things I tried. Its quite strange. I guess what I could do is try to have the output saved to another folder outside the document root and leave its file permissions at 777. Is this safe to do as the folder isn't web accessible?
 
I wouldn't recommend it. chown it to apache:apache (or relevant username.) If you're running as CGI you'll need to find the username responsible for php.
 
Just tried this and also the chmod function but they both report back saying operation not permitted. I guess they are disabled on my hosting. I had tried something like...

Code:
chown($file, $user); //$user was set to "root"

Any other ways around this?
 
Back
Top Bottom