Page 1 of 1

pass a txt file over a network through http protocol

Posted: Thu May 22, 2008 1:41 pm
by momukhtar
Hi

I want to pass a txt file using http from Apache server to another webserver. I searched php documentation and found the "http_send_file" function but it does not take any url like webserver root and desired folder where i want to send a file. Any help as to which function I shall use.

Re: pass a txt file over a network through http protocol

Posted: Thu May 22, 2008 2:29 pm
by VladSun
Could you explain the general purpose you are trying to achieve?

Re: pass a txt file over a network through http protocol

Posted: Thu May 22, 2008 2:44 pm
by momukhtar
The text file is generated in Apache server hosting php. I want to pass that txt file to another webserver which can process it.

Re: pass a txt file over a network through http protocol

Posted: Thu May 22, 2008 2:47 pm
by VladSun
You may use fopen()

Re: pass a txt file over a network through http protocol

Posted: Thu May 22, 2008 7:35 pm
by whiterabbit

Re: pass a txt file over a network through http protocol

Posted: Fri May 23, 2008 5:14 am
by panic!
a very simplistic solution

server one where the text file is stored

<?

$file_contents=file_get_contents('somefile.txt');

// might wanna encode $file_contents somehow here.

file_get_contents('http://someotherserver.com/saveText.php ... e_contents);

?>

on server two where you're saving the text file to call this saveText.php

<?
$file_contents=$_GET['text']);

// might wanna decode here ...


file_put_contents('somefile.txt, $file_contents);

?>

Re: pass a txt file over a network through http protocol

Posted: Fri May 23, 2008 7:13 pm
by momukhtar
Can I use http_put_file and just pass the url of second server and filename.

$response = http_put_file("http://localhost/savefile.cgi", filename);

Re: pass a txt file over a network through http protocol

Posted: Tue May 27, 2008 7:06 am
by panic!
yeah, if the file is accessible over http.