Re: Reading a file from another server
| From: | Chris Shiflett | Date: | Fri, 25 Jul 2003 22:05:26 +0000 |
| Subject: | Re: Reading a file from another server | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156945@lists.php.net to get a copy of this message | ||
--- Thomas <zaxisnet@hotmail.com> wrote:
> I'm having problems creating code to read a file from another
> server.
>
> 1. Is this even possible? with a secure server aswell?
Yes.
> 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;
> ?>
This code can be replaced with:
readfile('http://www.domain.com/test.txt');
As far as debugging problems related to this, check your php.ini and make sure
the URL wrapper is enabled. Otherwise, you will be restricted to your local
filesystem only.
Hope that helps.
Chris
=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/