Mark Mark - 1 year ago 134
PHP Question

Write Post data to file with PHP

I need to post data using the codes below, to php file that will save it in a text file.
i just don't know how to create the php file to receive the data below and save it in a text file.
as simple as possible.

Anyone can help, id really appreciated.

try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("stringData", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringData", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
String responseText = EntityUtils.toString(response.getEntity());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block

Answer Source

Simple as:

file_put_contents('test.txt', file_get_contents('php://input'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download