title: Unable to post image from Android device camera using HttpClient
body: <p>I'm attempting to post an image taken by the camera on an Android device and some other parameters, using the Apache Commons HttpClient.</p>
  
  <p>My post request works properly, and the parameters are read fine by the server, but my image does not upload.  The upload is handled by a PHP script and I can confirm that a proper HTTP Post will result in an image being successfully uploaded, as I've tested the PHP script using an HTML form. I can also confirm that photo != null in the code below.</p>
  
  <pre><code>HttpClient httpClient = new DefaultHttpClient();
  HttpPost postRequest = new HttpPost("http://myurl.com/upload.php");
  MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
  
  if (photo != null) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      photo.compress(CompressFormat.JPEG, 75, bos);
      byte[] data = bos.toByteArray();
  
      ByteArrayBody bab = new ByteArrayBody(data, "submission-1.jpg");
  
      reqEntity.addPart("file", bab);
  }
  
  reqEntity.addPart("date", new StringBody(date));
  reqEntity.addPart("lat", new StringBody(latitude));
  reqEntity.addPart("long", new StringBody(longitude));
  reqEntity.addPart("name", new StringBody(name));
  reqEntity.addPart("email", new StringBody(email));
  reqEntity.addPart("comments", new StringBody(comments));
  
  postRequest.setEntity(reqEntity);
  HttpResponse response = httpClient.execute(postRequest);
  </code></pre>