title: MultipartEntityBuilder sends no Post Variables
body: <p>I'm trying to upload a file, alongside some variables to a web service. From what I've read around the net, a MultipartEntityBuilder would be the tool for the job. However, when I use it in the described manner, the post variables (both text and file) don't seem to be sent with the query. The receiving end reacts just as if no post variables were attached.</p>
  
  <p>I've tried testing the theory by pointing the url at a file with the following code:</p>
  
  <pre><code>&lt;?php    
  $data = "";    
  foreach ($_POST as $key =&gt; $value) {
      $data = $data . "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."&lt;br&gt;";
  }
  echo $data;    
  ?&gt;
  </code></pre>
  
  <p>And the call returned no data (and did return data when I used other methods of posting.</p>
  
  <p>Are there any ideas as to what might be the problem?</p>
  
  <pre><code>The code in question:
  
          String url = "http://aktivthospital.dk.web1.aktivthospital.dk/index.php";
  
          HttpClient httpClient = new DefaultHttpClient();
          HttpPost httpPost = new HttpPost(url);
          httpPost.addHeader("Content-Type", "multipart/form-data");
  
          MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
          entityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
  
          ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8);
          entityBuilder.addPart("option", new StringBody("com_redtournament", contentType));
          entityBuilder.addPart("task", new StringBody("competition.apiServiceUploadImage", contentType));
          entityBuilder.addPart("username", new StringBody(_username, contentType));
          entityBuilder.addPart("password", new StringBody(_password, contentType));
          entityBuilder.addPart("comp_id", new StringBody(String.valueOf(_competitionId), contentType));
          entityBuilder.addPart("img_title", new StringBody(_title, contentType));
          File file = new File(_imagepath);
          entityBuilder.addPart("img_file",new FileBody(file));
          httpPost.setEntity(entityBuilder.build());
  
          HttpResponse response = httpClient.execute(httpPost);
  </code></pre>