在Grails中多文件上传 [英] Multiple File Upload in Grails
问题描述
我试图将优秀的 blueimp的jquery-file-upload Grails 2.0并为此编写一个新的插件。我知道有已经是一个插件,但它不使用资源,已经更新了9个月,jquery-file-upload在那个时候已经发生了很大的变化。
因此,我把所有的分布文件放在我的插件中,现在我正在尝试编写一个可以处理上传的控制器操作。问题是, request.getFileNames()
只给我一个文件[]
条目,我不知道以检索我上传的3个单独的文件。
如何处理由以下输入发送的文件:< input type = filename =files []multiple>
?
在表单中只有一个 input [type = file]
,如果我选择了几个文件,它们不会在同一个请求中发送。 query-file-upload
脚本会发送尽可能多的POST请求。这就是为什么 request.getFileNames()
每次只给我一个条目。我设法创建我的插件,它将很快出版。注意 http://grails.org/plugin/bootstrap-file-upload 。
I'm trying to integrate the excellent jquery-file-upload from blueimp into Grails 2.0 and to write a new plugin for that. I know there is already a plugin, but it doesn't use resources and it hasn't been updated for 9 months, and jquery-file-upload has changed a lot in that time.
So I put all of the files of the distribution in my plugin, and now I'm trying to write a controller action that can handle the upload. The problem is that request.getFileNames()
only gives me one files[]
entry and I don't know how to retrieve the 3 individual files I am uploading.
How do you handle the files sent by an input like this: <input type="file" name="files[]" multiple>
?
Actually I figured it out. There is only one input[type=file]
in the form and if I select several files they are not sent on the same request. The query-file-upload
script sends as many POST requests as there are files. That's why request.getFileNames()
only gives me one entry each time. I managed to create my plugin, it will be published soon. Watch out for http://grails.org/plugin/bootstrap-file-upload.
这篇关于在Grails中多文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!