How to send file by using http post method in android?
<p>i am implementing one app related to send file to server.</p>

<p>i am trying to send file to server by using http post method.</p>

<p>i am getting file from sd card by using the fallowing code.</p>

<pre><code>File root = Environment.getExternalStorageDirectory();
String pathToOurFile = root+"111";
</code></pre>

<p>My code is looking like as fallows.</p>

<pre><code>StringBuilder response = new StringBuilder();
try {
  HttpPost post = new HttpPost();
  post.setURI(uri);
  List params = new ArrayList();
  params.add(new BasicNameValuePair("paramName", "paramValue"));
  post.setEntity(new UrlEncodedFormEntity(params));
  DefaultHttpClient httpClient = new DefaultHttpClient();
  HttpResponse httpResponse = httpClient.execute(post);
  if (httpResponse.getStatusLine().getStatusCode() == 200) {
    Log.d(APP_TAG, "HTTP POST succeeded");
    HttpEntity messageEntity = httpResponse.getEntity();
    InputStream is = messageEntity.getContent();
    BufferedReader br = new BufferedReader(new InputStreamReader(
    openFileInput(pathToOurFile)));
    String line;

    while ((line = br.readLine()) != null) {
     Log.v("info",",,,"+line);
     response.append(line);
     }
   } else {
     Log.e(APP_TAG, "HTTP POST status code is not 200");
   }
} catch (Exception e) {
  Log.e(APP_TAG, e.getMessage());
}
</code></pre>

<p>but it is not woking properly .</p>

<p>if know the solution please help me</p>

<p>Thanks in advance.</p>
