Jump to content

Fopen and Curl give permission denied errors


Wienke

Recommended Posts

Whenever I use fopen or curl I always get a [i]"Warning: fopen(/tmp/test) [function.fopen]: failed to open stream: Permission denied" [/i] error. It happens when opening local files and http files. I am using php 5.1.4 and I have set safe mode to OFF and set allow_url_fopen to ON.

I am using this code
[code]
echo $url = "/tmp/test";
if ($handle = fopen($url, "r")) {
$xml = stream_get_contents($handle);
fclose($handle);
echo $xml;
} else {
echo "KRAK";
}
[/code]
I have "chmod 777"-ed the /tmp/test

When I do a normal curl or request as the apache user I can access the files.
I chmod-ed all the files to 777 but it still won't work. The funny thing is when I run the script on the command line with only php e.g. "sudo - u apache php /var/www/html/test.php" it works but if I run it through the webserver it gives the error.

So it could be that the problem lays within apache? Anyone ever seen this problem?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.