Remote file inclusion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
markj
Forum Newbie
Posts: 2
Joined: Fri Aug 09, 2002 10:05 am

Remote file inclusion

Post by markj »

Ok I'm just starting with PHP and could use a hand...:)

The goal is to remotely include a data.txt file from a remote source. This is a news source we would like to display on 3 seperate domains.

I have read and have beem doing trial/error with the fopen and include functions and it doesnt seem that anything I am trying is working.

The txt file path is http://www.domain.com/dir1/dir2/ssi/.txt file.

Anyone want to point me in the right direction?

Thanks in advance...:)
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Hmm... I was curious about opening remote files as well, so I tried this script:

Code: Select all

<html>
<head>
<title>Ham</title>
</head>
<body>

<?php

$incfile = fopen("http://duvet.vuse.vanderbilt.edu/RER/test.html","r");

$test = fgets($incfile, 1000);

fclose($incfile);

echo $test;

?>

</body>
</html>
The file opened just contained "Aiee!".

At first it gave me the "Cannot find server" page, then after a couple of reloads, it displayed "Aiee!" as it was supposed to, and viewing source showed the html claiming the title was "Ham", but IE 5.5 acted as if the title was "Cannot find server". In Mozilla it worked just fine, however.
markj
Forum Newbie
Posts: 2
Joined: Fri Aug 09, 2002 10:05 am

Post by markj »

Ahhhh I tried something similiar to that. With the html extension it works but not with a txt extension.

That's the problem I keep hitting....
Shadough
Forum Newbie
Posts: 20
Joined: Tue Jun 04, 2002 9:11 pm

Post by Shadough »

Have you tried readfile()
Post Reply