My code is working for one image when I upload more then one image it show error to me .
Can anybody help me in getting out this problem?
Using below code I am able to upload single Image , but I want to upload more then one Image so please help how can I upload Images. Thanks
Here is my code
String image_path=imageUrl1;
GetData(myFiles);
}
});
}
public void GetData(String myFiles)
{
String image_retrive_url="http://tradewale.com/open/tradedata.php?submitType=PostAd";
pDialog = new ProgressDialog(PostAddActivity.this);
pDialog.setMessage(" Sending...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
Bitmap bitmap = BitmapFactory.decodeFile(myFiles);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 30, stream);
byte [] byte_arr = stream.toByteArray();
String image_str = Base64.encodeBytes(byte_arr);
final ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
String Title = title.getText().toString();
String Description = description.getText().toString().trim();
String PhoneNumber = phonenumber.getText().toString();
String Email = email.getText().toString();
String Price = price.getText().toString();
nameValuePairs.add(new BasicNameValuePair("image",image_str));
nameValuePairs.add(new BasicNameValuePair("photo_url", image_retrive_url));
Thread t = new Thread(new Runnable()
{
@Override
public void run() {
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://tradewale.com/open/tradedata.php?submitType=PostAd");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
final String the_string_response = convertResponseToString(response);
}
catch(final Exception e)
{
runOnUiThread(new Runnable()
{
@Override
public void run()
{
Toast.makeText(PostAddActivity.this, "ERROR " + e.getMessage(), Toast.LENGTH_LONG).show();
}
});
System.out.println("Error in http connection "+e.toString());
}
}
});
t.start();
}