Mon code fonctionne pour une image lorsque je télécharge plus d'une image, elle montre une erreur.Comment envoyer plus d'une image au serveur
Quelqu'un peut-il m'aider à résoudre ce problème?
En utilisant le code ci-dessous, je suis en mesure de télécharger une seule image, mais je veux télécharger plus d'une image alors s'il vous plaît aider comment puis-je télécharger des images. Merci
Voici mon 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();
}
De cette façon, j'ai créé quatre méthodes différentes – user3492351
pas besoin de quatre méthodes différentes .. il suffit d'ajouter plus de paramètre. –
comment faire cela pouvez-vous me dire – user3492351