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.
pass a txt file over a network through http protocol
Moderator: General Moderators
Re: pass a txt file over a network through http protocol
Could you explain the general purpose you are trying to achieve?
There are 10 types of people in this world, those who understand binary and those who don't
Re: pass a txt file over a network through http protocol
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
You may use fopen()
There are 10 types of people in this world, those who understand binary and those who don't
-
whiterabbit
- Forum Newbie
- Posts: 14
- Joined: Thu May 22, 2008 6:58 pm
Re: pass a txt file over a network through http protocol
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);
?>
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
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);
$response = http_put_file("http://localhost/savefile.cgi", filename);
Re: pass a txt file over a network through http protocol
yeah, if the file is accessible over http.