Re: Reading a file from another server
| From: | Comex | Date: | Fri, 25 Jul 2003 22:06:09 +0000 |
| Subject: | Re: Reading a file from another server | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156946@lists.php.net to get a copy of this message | ||
<20030725214829.35730.qmail@pb1.pair.com>
Thomas:
> Hi Everyone.
>
> I'm having problems creating code to read a file from another server.
>
> 1. Is this even possible? with a secure server aswell?
> 2. I have tried using fopen() but this always gives me an
> error:
>
> Warning: stat failed for http://www.domain.com/test.txt
> (errno=2 - No
> such file or directory) in
> /home/domain/public_html/php/testphp/test.php on line 4
>
> this is my code:
> <?php
> $filename = "http://www.domain.com/test.txt";
> $handle = fopen ($filename, "r");
> $content = fread($handle, filesize ($filename));
> fclose($handle);
>
> echo $content;
>
>>
>
> can anyone help me. I need to put this on my server, and read this
> other file form a game server....but I can't seem to do it.
>
> Cheers for any help
Quote:
If PHP has decided that filename specifies a registered protocol, and that
protocol is registered as a network URL, PHP will check to make sure that
allow_url_fopen is enabled. If it is switched off, PHP will emit a warning
and the fopen call will fail.
But then again, that's not the error it gave...