title: Uploading files and other data from Android through Http POST request
body: <p>This is a simple way of posting files from Android. </p>
  
  <pre><code>String url = "http://yourserver.com/upload.php";
  File file = new File("myfileuri");
  try {
      HttpClient httpclient = new DefaultHttpClient();
  
      HttpPost httppost = new HttpPost(url);
  
      InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(file), -1);
      reqEntity.setContentType("binary/octet-stream");
      reqEntity.setChunked(true); // Send in multiple parts if needed
      httppost.setEntity(reqEntity);
      HttpResponse response = httpclient.execute(httppost);
      //Do something with response...
  
  } catch (Exception e) {
      e.printStackTrace();
  }  
  </code></pre>
  
  <p>What I want to do is add more <code>POST</code> variables to my request. How do I do that? While uploading plain strings in <code>POST</code> request, we use <code>URLEncodedFormEntity</code>.</p>
  
  <pre><code>httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  </code></pre>
  
  <p>Whereas while uploading files, we use <code>InputStreamEntity</code>.</p>
  
  <p>Also, how do I specifically upload this file to <code>$_FILES['myfilename']</code>?</p>