I have a file called updateServer.php that has the following code:
$myfile = fopen("http://173.XXX.XXX.XXX/myurl/demo/path.txt", "w") or die("Unable to open file!");
I want to use this file to edit the path.txt file that is placed on another server. Is this really possible as I am unable to do this.
I took help from this : http://php.net/manual/en/features.remote-files.php
PS : I over-writted the files on the same server and was successful in the same.
You can't write to URLs with fopen
. It only makes GET requests.
You could use the cURL
library to make an HTTP PUT request, but you would have to configure the server you are writing to to support PUT requests in that fashion. (Web servers do not by default because it would be insane for any HTTP client to be able to write files to any server).