如何编写自动提交表单(用于文件上传)?我试图onchange
在<input>
字段中添加:
@form(action = routes.Application.upload, 'enctype -> "multipart/form-data") {
<div class="fileupload fileupload-new" data-provides="fileupload">
<span class="btn btn-large btn-primary btn-file">
<span class="fileupload-new">Select file</span>
<span class="fileupload-exists">Change</span>
<input type="file" name="file" onchange="@routes.Application.upload()"/>
</span>
<span class="fileupload-preview"></span>
<a href="#" class="close fileupload-exists" data-dismiss="fileupload" style="float: none">×</a>
<input class="btn btn-success btn-large" type="submit" value="Submit!">
</div>
}
但它不起作用。有任何想法吗?我正在使用带有 Java 的 Play Framework 2