title: How to send multiple bitmap images to the server
body: <p>I want to send the multiple images to server.I have created the bitmap for each selected images.But the last bitmap image are send to the server.How to send all bit map images at once in android.I have tried like this</p>
  
  <pre><code>     class ImageUploadTask extends AsyncTask&lt;String, Void, String&gt; {
  
          String sResponse = null;
  
          @Override
          protected void onPreExecute() {
              // TODO Auto-generated method stub
              super.onPreExecute();
              dialog = ProgressDialog.show(Room_addroom1.this, "Uploading",
                      "Please wait...", true);
              dialog.show();
          }
  
  
  
          @Override
          protected String doInBackground(String... params) {
              try {
  
                  String url ="http://airbnb.abservetech.com/demo/public/mobile/hotel/roomsadd";
                  HttpClient httpClient = new DefaultHttpClient();
                  HttpContext localContext = new BasicHttpContext();
                  HttpPost httpPost = new HttpPost(url);
  
  
                  MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
                  int i=0;
                  mImageIds = new ArrayList&lt;String&gt;();
                  ByteArrayBody mImageByteArray = null;
                  for ( i = 0; i &lt; ImgData.size(); i++) {
  
  
                      Log.d("ImgData(i)--", String.valueOf(ImgData.get(i)));
  
                      Bitmap bitmap = decodeFile(ImgData.get(i));
  
                      String image = getStringImage(bitmap);
                      mImageIds.add(image);
                      Log.d("Image--", image);
  
                      ByteArrayOutputStream stream = new ByteArrayOutputStream();
                      bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
  
                      byteArray = stream.toByteArray();
  
  
                       mImageByteArray = new ByteArrayBody(byteArray, Long.toString(System.currentTimeMillis()) + ".jpg");
                      entity.addPart("room_images", mImageByteArray);
                      Log.d("ByteArray--", String.valueOf(mImageByteArray));
                    //  entity.addPart("room_images", mImageByteArray);
              }
                  Log.d("ByteArray-out--", String.valueOf(mImageByteArray));
  
                /*  entity.addPart("room_images", new ByteArrayBody(byteArray,
                          "image/jpeg", params[1]));*/
  
                  entity.addPart("user_id", new StringBody("52"));
                  entity.addPart("room_type",new StringBody( "premium"));
                  entity.addPart("room_prize", new StringBody("2356"));
  
                  httpPost.setEntity(entity);
  
  //                String entityContentAsString = new String(bos.toByteArray());
  //                Log.e("multipartEntitty:", "" + entityContentAsString);
                  ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  
                  entity.writeTo(bytes);
  
                  String content = bytes.toString();
                  String content1 = entity.toString();
           /*       Log.e("MultiPartEntityRequest:",content);
                  Log.e("MultiPartEntity---11:",content1);*/
                  HttpResponse response = httpClient.execute(httpPost,
                          localContext);
                  sResponse = EntityUtils.getContentCharSet(response.getEntity());
  
                  System.out.println("sResponse : " + sResponse);
              } catch (Exception e) {
                  if (dialog.isShowing())
                      dialog.dismiss();
                  Log.e(e.getClass().getName(), e.getMessage(), e);
  
              }
              return sResponse;
          }
  
          @Override
          protected void onPostExecute(String sResponse) {
              try {
                  if (dialog.isShowing())
                      dialog.dismiss();
  
                  if (sResponse != null) {
  
                      count++;
                      if (count &lt;ImgData.size()) {
                          Toast.makeText(getApplicationContext(),
                                  sResponse + " Photo uploaded successfully",
                                  Toast.LENGTH_SHORT).show();
  //                        new ImageUploadTask().execute(count + "", "hm" + count
  //                                + ".jpg");
                      }
                  }
  
              } catch (Exception e) {
                  Toast.makeText(getApplicationContext(), e.getMessage(),
                          Toast.LENGTH_LONG).show();
                  Log.e(e.getClass().getName(), e.getMessage(), e);
              }
  
          }
      }
  </code></pre>