I need to post data using the code 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.
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()); tv.setText(responseText); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block }
Simple as:
file_put_contents('test.txt', file_get_contents('php://input'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With