我有一个 upload
从 View 上的表单接收文件的操作。上传文件时完成验证。
如果文件无效,则再次显示 View 并输入 type="file"
value 应该指向上传失败的文件。
这似乎不起作用:( View 中的代码)
<input type="file" name="opt" value="${params.opt}" />
这是呈现给用户的:
<input type="file" name="opt" value="org.springframework.web.multipart.commons.CommonsMultipartFile@c9b839">
有任何想法吗?
最佳答案
由于安全原因,这似乎是不可能的,如果服务器知道路径,服务器可以访问可能包含私有(private)信息的客户端文件。
更多信息:How to set a value to a file input in HTML?
我可能需要让用户再次选择文件,或者执行 AJAX 文件上传之类的操作:http://blog.teamtreehouse.com/uploading-files-ajax
关于Grails文件上传: how to set the value of the input file when the view is rendered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30426186/