Announcement Announcement Module
Collapse
No announcement yet.
How to send MULTIPART_FORM_DATA in UTF-8 format Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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
    here

    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);

    restTemplate.getMessageConverters().add(
    new GsonHttpMessageConverter());
    restTemplate.getMessageConverters().add(
    new StringHttpMessageConverter());
    ResponseEntity<Success[]> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity,
    Success[].class);

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

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

    Comment


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

      Comment

      Working...
      X