Skip to content Skip to sidebar Skip to footer

Can I File_put_contents To Send To An Http Web Address?

I'm trying to have an event trigger that once it does it sends the content to a text file from another web address that I should have access to. I've tried the code below but it wi

Solution 1:

You cant do so using HTTP protocole. You can do it using FTP. Here is a sample of code to open and write file overt FTP.

$content = "Here is my content";
$fp = fopen("ftp://username:password@host/data/custom/alarm.txt","w");
fwrite($fp, $content);
fclose($fp);

Host can be IP address or just domain name. Another way is that you can create on the second server a WebService that will do the Job. So when event triggers you just call the WebService that will do the Job.

Solution 2:

As per PHP.net

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Post a Comment for "Can I File_put_contents To Send To An Http Web Address?"