I get the warning message: file_get_contents failed to open stream permission denied
I have set all_url_open to on in the php.ini file.
My php file is in my apache server and it is trying to access a url (that returns JSON) from a tomcat server on the same machine.
The code in the php file looks like:
$srcURL = 'http://samemachine:8080/returnjson/';
$results = file_get_contents($srcURL);
I have also tried curl and it returns nothing and doesn’t hit the tomcat server either:
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: en-us'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Why is permission denied?
allow_url_fopenand notall_url_openas you wrotephpinfo(). Make sure it lists the option as enabled. If it doesn’t restart your web serverlointerface