changes to transfer file from android to a php server
<p>Hi I wrote a code to transfer json object from android phone to php server as shown below. Can you please suggest me the changes required in my code if I want to transfer a file to the server.</p>

<pre><code>private String constructDataRecord(JSONObject data, String type)
{
    JSONObject dataRecord = new JSONObject();
    try
        {
            dataRecord.put("date", timeStr);
            dataRecord.put("time_stamp", c.getTimeInMillis());
            dataRecord.put("user", IMEI);
            dataRecord.put("type", type);
            dataRecord.put("ver", VER);
            dataRecord.put("data", data);
        }
        catch (JSONException e)
        {
            Log.e(TAG, "Exception", e);
        }

        String url = "http://mpss.csce.uark.edu/~smandava/index.php";
        Map&lt;String, String&gt; kvPairs = new HashMap&lt;String, String&gt;();
        kvPairs.put("data", dataRecord.toString());
        Log.d(TAG, "Exception");
        HttpResponse re = null;


        try {
            re = doPost(url, kvPairs);
            String  temp  = EntityUtils.toString(re.getEntity());
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


      //  if (temp.compareTo("SUCCESS")==0)
        {
     //       Toast.makeText(this, "Sending complete!", Toast.LENGTH_LONG).show();
        }

        return dataRecord.toString();
    }


   public static HttpResponse doPost(String url, Map&lt;String, String&gt; kvPairs) throws ClientProtocolException, IOException 
    {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(url);
        if (kvPairs != null &amp;&amp; kvPairs.isEmpty() == false) 
        {
            List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(kvPairs.size());
            String k, v;
            Iterator&lt;String&gt; itKeys = kvPairs.keySet().iterator();
            while (itKeys.hasNext()) 
            {
                k = itKeys.next();
                v = kvPairs.get(k);
                nameValuePairs.add(new BasicNameValuePair(k, v));
            }             
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        }
        HttpResponse response;
        response = httpclient.execute(httppost);
        return response;
    }
</code></pre>
