Grails 中的多文件上传 [英] Multiple File Upload in Grails
问题描述
我正在尝试将优秀的 jquery-file-upload from blueimp 集成到Grails 2.0 并为此编写一个新插件.我知道有已经是一个插件,但它不使用资源,而且没有更新了9个月,jquery-file-upload那段时间变化很大.
所以我将发行版的所有文件都放在了我的插件中,现在我正在尝试编写一个可以处理上传的控制器操作.问题是 request.getFileNames()
只给了我一个 files[]
条目,我不知道如何检索我上传的 3 个单独的文件.>
你如何处理这样的输入发送的文件:<input type="file" name="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屋!