When i am uploading single image to server code works fine , when i upload two images as string it show null-pointer exception. Can Anybody help me in this to send two or more images to server .\ Thanks Here is code for uploading image
String image_path=imageUrl1+","+imageUrl2;
GetData(image_path);
}
});
}
public void GetData(String image_path)
{
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(image_path);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 30, stream); //compress to which format you want.
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);
}