I want to send an image and a JsonObject to an PHP Server with MultipartEntity. Here is my Code:
HttpClient httpClient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(urlString); File file = new File(imageend); HttpResponse response = null; MultipartEntity mpEntity = new MultipartEntity(); ContentBody cbFile = new FileBody(file, "image/jpeg"); StringBody sb; try { sb = new StringBody(json.toString()); mpEntity.addPart("foto", cbFile); mpEntity.addPart("json", sb); httppost.setEntity(mpEntity); response = httpClient.execute(httppost); I can't read this in php because the format is like:
{\"test1\":\"Z\",\"test2\":\"1\"} I'm not able to read this in php because of the backslashes. If I post json without image over httppost and bytearrayentity there aren't any backslashes and I have no problem.
jsonobject?json.toString()return? Does contain these backslashes?