reading a remote file??

konekt

New Member
Messages
100
Reaction score
0
Points
0
#include < stdio.h>

file = fopen("FILEPATH", *);

Where * is:
r - reading
w - writing
a - appending

then fclose(file); to close

You can actually extract data using:
fscanf()
getc()
 
Last edited:

tittat

Active Member
Messages
2,478
Reaction score
1
Points
38
thanks konekt .its a new information.****repped********
 

sadm1r

New Member
Messages
9
Reaction score
0
Points
0
hm.
do you mean:
you have a page on this server, but you want to load a file from a remote server to add up to your web page.

you can do it by using include 'path/file'

where path/file is e.g. http://www.yourdomain.net/yourfile.html

that should load the web page as a part of your web page on other server.

e.g. you add:
Code:
<?php
include 'http://www.yourdomain.net/yourfile.htm';
?>
to the place where you want your other page to load.
you can use many other ways.

but if you mean on "reading the text files and echoing its content on your web page where you want them"...
well then you can use e.g.:

Code:
<?php
$pf = fopen("/pathyourfile","mode");
//fread, fgets, etc which you like the most
// instructions operations etc, e.g. you can redirect the
//output of fgets($pf) to variable like this:
$variable =fgets($pf);
fclose($pf);
?>
hints:
you use variable $pf as file pointer (something like c :)))
you MUST open a file before using any functions like fread() fgets() etc, ofcouse.
"mode" means one of various modes, e.g. "r" for read, "w" for write, "a" for appending ...
then after you opened your desired file, you use one of various operations (like th eones mentioned), to either write to an open file or read from it, reading whole line, the character only, reading whole file and puting into an array or whatever you want to do.
in the end after you finished the work with the file, you close the file with fclose().

hope it helped.
 
Top