CodeIgniter Forums
Message: file_get_contents(): https:// wrapper is disabled in the server configuratio - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Message: file_get_contents(): https:// wrapper is disabled in the server configuratio (/showthread.php?tid=70854)



Message: file_get_contents(): https:// wrapper is disabled in the server configuratio - mehuljogi - 06-09-2018

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



RE: Message: file_get_contents(): https:// wrapper is disabled in the server configuratio - InsiteFX - 06-09-2018

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



RE: Message: file_get_contents(): https:// wrapper is disabled in the server configuratio - skunkbad - 06-09-2018

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


RE: Message: file_get_contents(): https:// wrapper is disabled in the server configuratio - mehuljogi - 06-10-2018

(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.


RE: Message: file_get_contents(): https:// wrapper is disabled in the server configuratio - ragingTorch - 06-11-2018

(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.


RE: Message: file_get_contents(): https:// wrapper is disabled in the server configuratio - InsiteFX - 06-11-2018

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();