Jay
Jay

Reputation: 2107

Http Inbound Request page - POST

I'd like to set up a HTTP page that 'listens' for a HTTP POST from another page. Upon receiving this. It writes the 'posted text' to a .txt file.

Could someone suggest how I would go about this please?

Upvotes: 0

Views: 126

Answers (1)

alanmanderson
alanmanderson

Reputation: 8200

The easiest way to create an actionable http page is with php. Here is an example of a php page that gets a POST request and writes data to a file. Save this to write.php (for example)

<?php
    $data = $_POST['var1'];
    file_put_contents("foo.txt", $data);

This will write the data in the var1 variable of the post to the file foo.txt.

If this needs to be called from another page, you just need to add the following on that other page:

include "write.php";

Upvotes: 1

Related Questions