[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 844
  • Last Modified:

PHP Apache Unix open / write files on different server

I'm familiar with writing and reading files located on the same server that my PHP or Perl script is running, but what if I needed to write/read files located on a different server?  Server A needs to write to and read content on Server B.  (I have permissions to read and write on both Server A and Server B.)  

In the case of PHP, would I use fsockopen or fopen?  Can you give examples of a simple read/write in Perl and/or PHP where the script, executing on Server A (10.10.10.1), is reading/writing to Server B (10.10.10.2) assuming all permissions are set up correctly?

Thank you,
$marc

0
marcparillo
Asked:
marcparillo
  • 4
  • 3
1 Solution
 
OscurochuCommented:
There really is no way to write to a different server with PHP... what I would do is just create a script on server A that sends the data to server B, and the script on server B writes the data received. vice-versa.
0
 
marcparilloAuthor Commented:
So Server A sends the data to Server B via POST and Server B just waits for the data?
0
 
OscurochuCommented:
pretty much
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
marcparilloAuthor Commented:
What about the PHP function fopen?  I noticed in the on-line PHP manual this example that looks like the protocol for writing to a file on a different server:

("ftp://user:password@example.com/somefile.txt", "w");

0
 
OscurochuCommented:
You can read files from a different server but you cannot write to a different server.
0
 
marcparilloAuthor Commented:
If that was the case, then why would the PHP manual show an example of an fopen function that appears to be able to write to a different server via FTP?  

Am I not understanding this correctly?
0
 
OscurochuCommented:
You can use fopen to write to an FTP server, I forget about that. That is the only way to write to a different server. Sorry, my mistake.

Please refer me to the php manual page you are talking about if that does not end your confusion.
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now