views:

36

answers:

1

I tested this script on another server and it worked fine. Do I have to set my php.ini file? And how?

<?php

ini_set('allow_url_fopen', 1);

if (!isset($_GET['url'])) {
    exit();
}

echo file_get_contents($_GET['url']);

?>
+4  A: 

From the PHP Manual on allow_url_fopen

Note: This setting can only be set in php.ini due to security reasons.

Open the PHP.ini file with an editor and change the setting accordingly. If this on shared hosting and you do not have access to the PHP.ini contact your hosting service and ask them if they could change the setting.

Gordon
I don't have access to the standard php.ini file, but I can use another file, so how do I create a php.ini file?
@user376919 if this is a server you own, you do have access to the php.ini. If this is a shared host, then writing a new ini will accomplish nothing, because you wont be able to tell the webserver to actually use it. Like I said, contact (or change) your hosting service.
Gordon
The hosting service says I can edit it myself by putting a new php.ini file inside /private, so I just have to write a new one. The question now is: How?
@user376919 ok, in this case, ask the Hosting Service if it is possible to get a copy of the default PHP.ini, because you want it to be as close as possible to this one. If they won't do this, download PHP from php.net. The archives usually contain php.ini files you can modify to you liking.
Gordon