am developing an application that can send an image and a user's first name and second name to the server. The application can send the image to the server but I have failed to retrieve user's first name and second name. Below is my code
java
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(
"http://192.168.1.144/app_api/samplerEG.php");
MultipartEntity entity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG, 100, bos);
byte[] data = bos.toByteArray();
entity.addPart("fname", new StringBody(user_fname));
entity.addPart("lname", new StringBody(user_lname));
entity.addPart("file", new ByteArrayBody(data, "picture.jpg"));
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost,
localContext);
BufferedReader reader = new BufferedReader(
new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));
String sResponse = reader.readLine();
return sResponse;
and php is
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$date_of_birth = $_POST["dob"];
$pnumber = $_POST["pnumber"];
$district_name = $_POST["district_name"];
$gender = basename($_POST['gender']);
$picture = md5(basename($_FILES['file']['name'])).".jpg";
Where could I be going wrong
You only need to use FileBody instead of