Good morning.thanks for read me. I'm trying to send a form with an input type file, and then preview it. alll with ajax or thing similar
-------------------------------
Load.html
#{form @Application.load(), enctype:'multipart/form-data'}
<input name="file" id="inputFileSF" onchange="preLoad(this.form)" type="file">
#{/form}
<div id="divPreview"> </div>
-------------------------------
Preview.html
<img style="width:180px;max-height:auto;" src="@{Application.preview()}">
-------------------------------
JavaScripth:
function preLoad(frm)
{
frm.submit( function() {
$.ajax({
type: 'POST',
url: '@Application.load()',
data: $(this).serialize(),
success: function(data) {
alert("workin ok")
}
})
return false;
} );
/*update the div*/
var actionui = #{jsAction @Application.preview()/}
$("#divPreview").load(actionui({}), function(){ })
}
-------------------------------
Application.java
public static File tmpFile;
public static void load(File file) {
if (file != null){
System.out.println("goooo ok" );
tmpFile = file;
}
else System.out.println("null");
}
public static preview(){
renderBinary(tmpFile);
}
------------------------------------------
But no working.
What am I doing wrong?
pd: sorry for the english... but i'm from peru.
thanks