URL file access -> PHP

URL file access -> PHP

Posted by: RaelRiaK
Posted on: 2006-07-13 01:24:00

Good morning
This is my first post on the forum, so please, be nice with me :)

So i have a probleme with the php function fopen. I try to make a fopen on an ftp url, and the server answer me that the "URL file-access is disabled in the server configuration".

Do you know how to enable it, because i really need this function!

PS: it works perfectly on me Xampp local server

Thanks a lot

Renaud

Re: URL file access -> PHP

Posted by: Raz2133
Posted on: 2006-07-13 02:09:00

In reply to:

Good morning
This is my first post on the forum, so please, be nice with me :)


Good evening (well it is evening here :) welcome to the forum.

In reply to:

"URL file-access is disabled in the server configuration"


The error message is correct. For security reasons, the default DreamHost PHP install has the allow_url_fopen option disabled. Unfortunately, this being shared hosting, you do not have access to the php.ini file to change this.

There are a number of ways to overcome this limitation. The first and probably the easiest, is to modify your code to use CURL.

http://www.wiki.dreamhost.com/index.php/CURL

Another option is to copy the PHP executable and php.ini file to your local directory and create/modify your .htaccess file to use this local version. You can then modify this local php.ini file to enable allow_url_fopen.

http://wiki.dreamhost.com/index.php/PHP.ini

The third option is much like the one above, but instead of copying the DreamHost PHP executable, you compile a custom PHP executable.

http://wiki.dreamhost.com/index.php/Installing_PHP5

Mark

Re: URL file access -> PHP

Posted by: RaelRiaK
Posted on: 2006-07-13 03:30:00

Thanks for replying
cURL seems to be cool, but i have one probleme!

when i try to give this kind of url :
ftp://login:password@host/folder/subfolder
it doesn't work at all!

Can you help me ?

Re: URL file access -> PHP

Posted by: Raz2133
Posted on: 2006-07-13 04:00:00

In reply to:

when i try to give this kind of url :
ftp://login:password@host/folder/subfolder
it doesn't work at all!


That is odd. I just tried the following code, copied from the wiki article, and it retrieved a text file from my ISPs FTP and displayed it correctly.

<?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'ftp://username:password@myisp.net.au/test.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);

// display file
echo $file_contents;
?>


Mark

Re: URL file access -> PHP

Posted by: RaelRiaK
Posted on: 2006-07-13 05:38:00

Yes it's true, it works! My probleme is another one on the same mini project ! I'm gonna post another thread for this problem :)

Thanks a lot for helping me with cURL, it's a very cool thing!

Re: URL file access -> PHP

Posted by: pangea33
Posted on: 2006-07-13 16:49:00

Original:
when i try to give this kind of url :
ftp://login:password@host/folder/subfolder
it doesn't work at all!

Tags: file accessurl