Android post Base64 String to PHP

前端 未结 5 531
星月不相逢
星月不相逢 2020-11-30 14:57

------ Solution ------
The issue was on our server. It can only handle post requests if we put www in front of our domain name. So that\'s what

5条回答
  •  孤城傲影
    2020-11-30 15:17

    Try sending your data as below:

    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, 60000);  //1 min
    HttpConnectionParams.setSoTimeout(httpParams, 60000);          //1 min
    
    HttpClient client = new DefaultHttpClient(httpParams);
    HttpPost post = new HttpPost("http://myURL/uploadImage.php");
    
    List pairs = new ArrayList();
    pairs.add(new BasicNameValuePair("image", image_str));
    
    post.setEntity(new UrlEncodedFormEntity(pairs, HTTP.UTF_8));   // as UTF-8
    HttpResponse response = client.execute(post);
    

提交回复
热议问题