How can I write an auto submit form (for file uploading)? I’ve tried to add onchange in <input> field:
@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>
}
but it does not work. Any ideas? I’m using Play Framework 2 with Java
You should check on your own eyes how does it look in the code. in your
onchangeattribute you put just an url, and for browser it has no sensible meaning.Instead you should put there name of some JavaScript method to perform, ie: