I would like to upload an image by sending the image to a php script. It works fine if the internet connection is good. But sometimes it does not work. E.g. when the internet connection is slow. So I'm looking for a way to upload the image with a slow connection. What can I do? The filesize is already quite small, about 40kb. The code should try to upload the image until it is done.
Edit: Code for the upload:
public void upload(String uploadImage){
SharedPreferences settings = getSharedPreferences("App", 0);
String emailaddress = settings.getString("mailaddress", null);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("image",uploadImage));
nameValuePairs.add(new BasicNameValuePair("email", emailaddress));
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://domain.de/uploadImage.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
try {
Thread.sleep( 10000 );
}catch (InterruptedException e1) {
e1.printStackTrace();
}
upload(uploadImage);
}
}