Reputation: 881
I created a file upload in Grails, but I can't find a way to get the request to use Content-Type:multipart/form-data
. The requests are being sent with
Content-Type:application/x-www-form-urlencoded
.
This is my form
<g:uploadForm controller='asset' action='upload'>
<label>Select file(s) to upload</label>
<input type='file' id='fileUpload' name='filesToUpload' multiple />
<g:submitButton name="upload" value="Upload"/>
</g:uploadForm>
In Config.groovy, grails.mime.types
contains multipartForm: 'multipart/form-data'
and grails.web.disable.multipart=false
. I am using Spring Security, and the AssetsController
is @Secured
.
How do I get the requests to be sent with Content-Type:multipart/form-data
?
Upvotes: 2
Views: 567
Reputation: 11052
if the <g:uploadForm >
-Tag does not what's described in the manual:
http://grails.github.io/grails-doc/2.5.x/ref/Tags/uploadForm.html
Identical to the standard form tag except that it sets the enctype attribute to "multipart/form-data" automatically.
then you could try to use the normal <g:form >
-Tag and add the enctype attribute or even don't use the tag at all. A simple HTML-Upload will work, too:
<form action="${g:createLink controller:'', action:''}" method="post" enctype="multipart/form-data">
<input type="file" name="fileupload">
<input type="submit" name="upload">
</form>
Upvotes: 1