• Register
1 vote
80 views

Problem :

I have very recently started earning PHP. Now I am facing below error if I try to run the script. Please find the error message as below for your reference.

Warning: file_get_contents() [function.file-get-contents]: https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/satoship/public_html/connect.php on line 22

I have done the required research on this error and now I know this is the server related issue but still I am unaware of the steps those I need to take to fix above server error.

8 5 2
3,230 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had faced this issue in the past. I had also done a lot of research and found solution on it. So to fix my issue I wrote below function and it fixed my issue. You can also use below function to fix your issue.

<?php
$phpurl = "http://www.example.org/";
$phpch = curl_init();
curl_setopt ($phpch, CURLOPT_URL, $phpurl);
curl_setopt ($phpch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($phpch, CURLOPT_RETURNTRANSFER, true);
$phpcontents = curl_exec($phpch);
if (curl_errno($phpch)) {
  echo curl_error($phpch);
  echo "\n<br />";
  $phpcontents = '';
} else {
  curl_close($phpch);
}

if (!is_string($phpcontents) || !strlen($phpcontents)) {
echo "Failed to get the required phpcontents.";
$phpcontents = '';
}

echo $phpcontents;
?>

Also you need to edit your php.ini and you need to find allow_url_fopen in it and set it to allow_url_fopen = 1

Hope above solution helps.

8 4 1
5,680 points

Related questions

0 votes
1 answer 828 views
828 views
Problem : When I am trying to upload the csv file with zipcode it will convert and save the latitude and logitude. A error is occurring to convert a zipcode to lat,lng. In the localhost its working very fine. But when I am trying to upload it in the live server. I am ... the google api key also. I am unable to add php.ini file. If I try to upload php.ini file then it shows internal server error.
asked Jan 31, 2020 jwilliam 3.9k points
0 votes
1 answer 35 views
35 views
Problem: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0
asked Feb 23 Muneeb Saadii 130k points
0 votes
1 answer 11 views
11 views
Problem: Any idea how to solve this error?
asked Mar 12 Ifra 36.4k points
0 votes
1 answer 32 views
32 views
Problem session_start(): open(session_file, o_rdwr) failed: permission denied (13)
asked Feb 9 charles mathews 5.5k points
0 votes
1 answer 9 views
9 views
Problem: Any ideas on how to fix this > Warning: assignment makes integer from pointer without a cast [enabled by default]
asked Apr 25 ummeshani 9.5k points
1 vote
1 answer 3 views
3 views
Problem: How to avoid this error? Conversion from type dbnull to type integer is not valid.
asked Apr 27 PkGuy 23.5k points
0 votes
1 answer 41 views
41 views
Problem presenting view controllers on detached view controllers is discouraged
asked Feb 11 charles mathews 5.5k points
0 votes
1 answer 2 views
2 views
Problem: I run the following C codes and got a warning: control reaches end of non-void function int main(void) {} Any suggestions?
asked Apr 20 munim01 21k points
0 votes
1 answer 187 views
187 views
Problem: ties should not be present for the kolmogorov-smirnov test
asked Feb 19 Dan phillip 4.8k points