Announcement Announcement Module
No announcement yet.
How to send MULTIPART_FORM_DATA in UTF-8 format Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to send MULTIPART_FORM_DATA in UTF-8 format

    I'm using spring for android. I want to create registration form in my android app. The user maybe fill out the form with utf-8 format but when data send to server and store in MySQL database I find ?????? in my database field.table's column type set to utf8_general_ci. My question is:
    Do I need to set something for content type in php page OR I need set UTF-8 in my android code?
    Here is my code I'm using: I did same as

    File cacheDirectory = context.getFilesDir();
    tmpFile = new File(cacheDirectory.getPath() + "/" + "avatar.png");
    Resource file = new FileSystemResource(tmpFile);

    MultiValueMap<String, Object> formData = new LinkedMultiValueMap<String, Object>();
    formData.add("firstName", " registerFields[0]");
    formData.add("lastName", registerFields[1]);
    formData.add("userName", registerFields[2]);
    formData.add("file", file);

    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.setContentType(MediaType.MULTIPART_ FORM_DATA);
    HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(
    formData, requestHeaders);

    // Create a new RestTemplate instance
    RestTemplate restTemplate = new RestTemplate(true);

    new GsonHttpMessageConverter());
    new StringHttpMessageConverter());
    ResponseEntity<Success[]> response =, HttpMethod.POST, requestEntity,

    return response.getBody();
    Last edited by misaghdroid; Feb 16th, 2013, 05:19 AM.

  • #2
    I see from this question on StackOverflow that you solved this problem by configuring your mysql query on the server.


    • #3
      Yes,exactly my problem solved that way.