title: MultipartEntity POST android
body: <p>I'm implementing app upload file by android.I have a service : <a href="http://example.com:1001/UPLOAD/FileUpload.do" rel="nofollow">http://example.com:1001/UPLOAD/FileUpload.do</a>. I want to upload a file and two parameter like that</p>
  
  <p>0?event=Upload&amp;type=:1 </p>
  
  <p>:0 SERVER [current http://example.com:1001/UPLOAD/FileUpload.do] </p>
  
  <p>:1 {invoice, signature} </p>
  
  <p>:2 File on form with name: UploadedFile </p>
  
  <p>When I copy and paste : <a href="http://example.com:1001/UPLOAD/FileUpload.do" rel="nofollow">http://example.com:1001/UPLOAD/FileUpload.do</a> on browser then it response a form like that</p>
  
  <p></p>
  
  <pre><code>&lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
      &lt;form enctype="multipart/form-data" action="FileUpload.do" method="post"&gt;
          &lt;input type="file" name="UploadedFile"&gt;&lt;/input&gt;
          &lt;input type="hidden" value="invoice" name="type"&gt;&lt;/input&gt;
          &lt;input type="submit" value="Upload" name="event_Upload"&gt;&lt;/input&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is my code android:</p>
  
  <pre><code>HttpClient httpClient = new DefaultHttpClient();           
  HttpPost httpPost = new HttpPost("http://example.com:1001/UPLOAD/FileUpload.do");
  File file = new File(pathFile);
  FileBody fileBody = new FileBody(file);
  
  MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
  reqEntity.addPart("event", new StringBody("Upload"));
  reqEntity.addPart("type", new StringBody("invoice"));
  reqEntity.addPart("UploadedFile", fileBody);
  
  httpPost.setEntity(reqEntity);              
  httpClient.execute(httpPost);
  </code></pre>
  
  <p>But I don't know , why it doesn't upload to server . What's wrong???</p>