bdev
bdev

Reputation: 11

request.GetFile cannot get UTF-8 charset content

I am getting an error when uploading a file with UTF-8 characters as multipart/form-data in Grails.

I am using the Form below;

<form action="uploadPost" enctype="multipart/form-data; charset=utf-8" method="POST">
    <label class="form-titles" for="csvList">Choose a file: </label>
<input type="file" id="csvList" name="csvList" style="width: 200px;"/>
    <input type="submit"/>

In the controller I have:

def file = request.getFile('csvList')

This causes the error:

ERROR [org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver] - No signature of method: org.springframework.security.wrapper.SavedRequestAwareWrapper.getFile() is applicable for argument types: (java.lang.String) values: [userList] Possible solutions: getXML(), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getLocale(), getJSON()>

I think this will be same in Java.

Any idea what I am doing wrong and how to get UTF-8 charset in multipart form?

Upvotes: 1

Views: 1023

Answers (2)

user800014
user800014

Reputation:

I think that's because you declared the utf8 inside the enctype and the server didn't understand as a multipart. Try:

<form method="post" action="uploadPost" enctype="multipart/form-data" accept-charset="UTF-8">

Upvotes: 0

Louis Ricci
Louis Ricci

Reputation: 21086

enctype="multipart/form-data"

Don't put a charset in the "enctype" attribute.

Upvotes: 0

Related Questions