[Sussex] Getting files from a remote web server in a PHP script

Mark Harrison (Groups) mph at ascentium.co.uk
Sat Oct 22 19:07:13 UTC 2005


On Sat, 2005-10-22 at 19:46 +0100, Steve Dobson wrote:
> 
> 
> I need to write a little script to fetch HTML files from a remote
> web server from within a PHP script.  Now I could use system()
> to call wget and do it that way.
> 
> But I was wondering is there a better way (more direct) of getting 
> the remote data?

fopen supports http as if it were a file system, so you can do stuff
like:

$myfile = fopen("http://www.remoteserver.com/mydirectory/myfile", "r");

However, there's a server-wide boolean called allow_url_fopen that needs
to be set to true for this to work.


Regards,

Mark







More information about the Sussex mailing list