title: send multiple image to server : One image sending thrice to server issue
body: <ul>
  <li><p>I have to send three different images in server side.Right now one
  image is uploading thrice.But I have chosen three different image.</p></li>
  <li><p>Because I had given count=0.then it takes first image and send the
  first image thrice to the server.</p></li>
  <li><p>If I give the count=1 then it takes the second image thrice to send
  to the server at a time.</p></li>
  <li><p>I don't know how to give a count for 0,1 and 2 at a time to send the
  three images.So that I can send the three images at a time to send it to the server.</p></li>
  </ul>
  
  <p><strong>Logcat:</strong></p>
  
  <pre><code>02-11 04:32:20.565: E/params[0](16395): 0
  02-11 04:32:20.582: E/ParamsArray(16395): [0, pk0.jpg]
  </code></pre>
  
  <p><strong>MainActivity.java:</strong></p>
  
  <pre><code>  public class MainActivity extends Activity {
  
      private Button upload, pick;
      MultipartEntity entity;
      GridView gv;
      int count = 0;
      public ArrayList&lt;String&gt; map = new ArrayList&lt;String&gt;();
      Bundle b;
      TextView noImage;
  
  
     @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
       upload.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View v) {
                  new ImageUploadTask().execute(count + "", "pk" + count + ".jpg");
  
                  /*Log.e("url", url);
                  new UserProfileUpdateAsynTask().execute(url);*/
              }
          });
  }
  
  class ImageUploadTask extends AsyncTask&lt;String, Void, String&gt; {
  
  
          ProgressDialog dialog;
          String url = "";
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              dialog = new ProgressDialog(MainActivity.this);
              dialog.setMessage("Loading...");
              dialog.setCancelable(false);
              dialog.show();
          }
  
          @Override
          protected String doInBackground(String... params) {
  
              HttpEntity resEntity;  
  
              int i = Integer.parseInt(params[0]);
              Log.e("params[0]",""+i);
  
              Bitmap bitmap = decodeFile(map.get(i));
              HttpClient httpClient = new DefaultHttpClient();
              HttpPost httpPost = new HttpPost(url);
              entity = new MultipartEntity();
  
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              bitmap.compress(CompressFormat.JPEG, 100, bos);
              byte[] data = bos.toByteArray();
  
              try {
  
                  Log.e("ParamsArray",""+Arrays.toString(params));
  
  
  
              entity.addPart("filename[0]", new ByteArrayBody(data,"image/jpeg", params[1]));
              entity.addPart("filename[1]", new ByteArrayBody(data,"image/jpeg", params[1]));
              entity.addPart("filename[2]", new ByteArrayBody(data,"image/jpeg", params[1]));
  
  
                  httpPost.setEntity(entity);
                  HttpResponse response = httpClient.execute(httpPost);
                  resEntity = response.getEntity();
                  String entityContentAsString = EntityUtils.toString(resEntity);
  
                  return entityContentAsString;
  
              } catch (UnsupportedEncodingException e) {
                  e.printStackTrace();
              } catch (ClientProtocolException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
              return null;
  
          }
  
          @Override
          protected void onPostExecute(String result) {
              super.onPostExecute(result);
  
              if (result != null) {
                  dialog.dismiss();
                  Log.e("Update_profile", result);
  
              }
          }
  
      }
  
  
  
  }
  </code></pre>
  
  <p>Anyone can help me with this.Thank You.</p>