• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Message: file_get_contents(): https:// wrapper is disabled in the server configuratio

#1
I am trying below code to get city detail from thirdparty website using one of my controller file


PHP Code:
$target_url "https://ziptasticapi.com/{$zip}";
$cityInfo file_get_contents($target_urlFILE_USE_INCLUDE_PATH); 


But I am getting below errors, I already tried allow_url_fopen = On & allow_url_include = On in php.ini file, it getting issue with php7.0 while I am using php 5.6 It works fine. So please let me guide its codeigniter issue or server? I am using same above code in external file than it works fine, but while I am using above code with controller it gives error with php7.0.

Quote:Severity: Warning
Message: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0
Filename: controllers/Quotes.php
Line Number: 283

Backtrace:

File: /home/wprcf/public_html/admin/application/controllers/Quotes.php
Line: 283
Function: file_get_contents

File: /home/wprcf/public_html/admin/index.php
Line: 315
Function: require_once

A PHP Error was encountered
Severity: Warning
Message: file_get_contents(https://ziptasticapi.com/46220): failed to open stream: no suitable wrapper could be found
Filename: controllers/Quotes.php
Line Number: 283

Backtrace:

File: /home/wprcf/public_html/admin/application/controllers/Quotes.php
Line: 283
Function: file_get_contents

File: /home/wprcf/public_html/admin/index.php
Line: 315
Function: require_once
Reply

#2
php.ini

Code:
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen=On
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
I'm not saying it's your problem, but you're not using the context parameter correctly, if that was your intention.

See example #4:
http://php.net/manual/en/function.file-get-contents.php
Reply

#4
(06-09-2018, 09:12 AM)InsiteFX Wrote: php.ini

Code:
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen=On

I already on it, but while I am using my code with my controller file of the codeignitter framework than it not works let me know if you have another option, I already tried curl but give me error like undefined curl_init() function. I already on library using php.ini file for curl too.
Reply

#5
(06-10-2018, 10:20 PM)mehuljogi Wrote:
(06-09-2018, 09:12 AM)InsiteFX Wrote: php.ini

Code:
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen=On

I already on it, but while I am using my code with my controller file of the codeignitter framework than it not works let me know if you have another option, I already tried curl but give me error like undefined curl_init() function. I already on library using php.ini file for curl too.

You might be editing the wrong php.ini

Create a test.php, put phpinfo() in it and then access it. It will tell you many things and one of them will be the location the php.ini file, that's the one you need to edit. Don't forget to restart your server after saving php.ini for it to take effect.
Reply

#6
And make sure you delete the test.php file when your finished!

It's also a good idea to do an:

PHP Code:
ob_start();

// Your code

ob_end_flush(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.