• Register
1 vote
52 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
5,680 points

Related questions

0 votes
1 answer 590 views
590 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 5 views
5 views
Problem: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0
asked 3 days ago Muneeb Saadii 2.4k points
0 votes
1 answer 8 views
8 views
Problem session_start(): open(session_file, o_rdwr) failed: permission denied (13)
asked Feb 9 charles mathews 3.8k points
0 votes
1 answer 7 views
7 views
Problem presenting view controllers on detached view controllers is discouraged
asked Feb 11 charles mathews 3.8k points
0 votes
1 answer 25 views
25 views
Problem I am building an application using PHP 7.2. One of its features is ability to upload files, which are stored on the server but for some files I am getting: file size exceeded the maximum size permitted I get this error message for the files, which are larger than 2M. It ... ! I guess it is related to some php.ini black magic, but I am new in php, what should I do to resolve this issue?
asked Nov 12, 2020 alexh 2.5k points
0 votes
1 answer 22 views
22 views
Problem: ties should not be present for the kolmogorov-smirnov test
asked Feb 19 Dan phillip 1.9k points
0 votes
1 answer 512 views
512 views
Problem : Currently I am facing many problems because of below message I have tried everything that I could, but below message is not going away: &ldquo;The secret passphrase in configuration (blowfish_secret) is too short.&rdquo; I am working on Windows, I have already restarted ... to clear the browser history and cookies in my browser but still I am facing the error. How can I fix the error?
asked Feb 24, 2020 mphil 2.3k points
0 votes
2 answers 249 views
249 views
Problem : I have just upgrade from Magento 1.9.3.3 (form key disabled) to the 1.9.3.7. Now I cannot login to a backend. My error message is 'You did not sign in correctly or your account is temporarily disabled.' I tried to reset my cookie domain, ... are many posts that are concerning magento 2, but far less talking about the magento 1. Does someone with magento 1 had and solved above issue?
asked Jan 18, 2020 jwilliam 3.9k points
0 votes
1 answer 82 views
82 views
Problem: I am getting this error everytime I open my server. I need someone to help me how to remove this error?
asked Nov 14, 2020 prog_learner 2.5k points