Uploading an image from android to a PHP server -


I am trying to upload an image from Android to a PHP server, but I had difficulty using multipartytyty The problem, progress dialog steel, provides my code without any code here:

  public string postfunction (string s_v1, string s_v2, string s_v3) ParseException, ClientProtocolException, IOException throws { HttpClient httpclient = new DefaultHttpClient (); Http post httppost = new HTTP post (S_V1); // Required Apache-mime4j-0.6, and httpmime-4.0.3 Multipart Antipp MP = New Multipart Antty (HTT Multipartmode.brasassimpatable); Mp.addPart ("choix", new stringbody ("2"); Boolean exists (= new file ("/ data / data / my pocket / file / avatar.jpg")). is present (); If (! Is present) {Log.i (tag, "no file"); } Other {file tempImg = new file ("/ data / data / my pocket / file / avatar.jpg"); File body bin = new file body (tempImg, "image / jpg"); Mp.addPart ("photo_r", bin); } Mp.addPart ("mystring1", new stringbodie (s_v2, charset. Name ("UTF-8"); Mp.addPart ("mystring2", new stringbodie (s_v3, charset. Name ("UTF-8")) ; Httppost.setEntity (mp); log.i (tag, "start"); httpResponse response = httpclient.execute (httppost); log.i (tag, "end"); return response;}  

I do not know where the problem is !! Thanks a lot;)

problem Solution, it was due to my low internet connection, now I try SocketTimeoutException with connection time Received which is generated in the emulator, but unfortunately Acer Liquid in my phone!


Comments