0

Currently, my script needs an input from user which will then do a HTTP Post (using curl) and the response will be another url to download a file and when user clicked on it will trigger download of the file into user's pc.

Now all this are working but I need to change the flow to this:

  1. After input from user, http post must be from the server rather than from the user's machine.
  2. Subsequent file download will also be into the server and subsequently showed to user.

For 2) I am using the following PHP download to server instead of client

For 1), how do I do http post from server rather than from client after input from user?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
aandroidtest
  • 1,493
  • 8
  • 41
  • 68

1 Answers1

1

You can use the Curl library to perform POST operations from your server. Try this -

$url = "http://www.example.com/submit.php";
$fields = "field1=" . $value1 . "&field2=" . $value2;
$conn = curl_init();
curl_setopt($conn, CURLOPT_URL, $url);
curl_setopt($conn, CURLOPT_POST, 2);
curl_setopt($conn, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec($conn);
curl_close($conn);
Pranav Negandhi
  • 1,594
  • 1
  • 8
  • 17