Page 1 of 1

Remote file inclusion

Posted: Fri Aug 09, 2002 10:05 am
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...:)

Posted: Fri Aug 09, 2002 10:52 am
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.

Posted: Fri Aug 09, 2002 1:18 pm
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....

Posted: Fri Aug 09, 2002 4:25 pm
by Shadough
Have you tried readfile()