Seguinte, eu tenho uma aplicação que faz o upload de imagem para o banco de dados. Existe uma tela onde eu pego essa imagem mostro na tela e se estiver tudo certo eu envio para o banco de dados. Esse “mostrar na tela” o preview como a gente chama fica a cargo desse codigo abaixo que estou enviando para voces analisarem. O meu problema é que esse codigo sozinho como um html funciona, bastando eu autorizar a execução do script no browser. Porem se eu jogo esse html no tomcat ou transformo ele em jsp esse preview para de funcionar e não aparece aviso na tela para autorizar o script, ele apenas não funciona. Não consigo fazer o preview funcionar. Alguem poderia me ajudar ?? Um abraço a todos !! Segue o codigo…
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “<a href="http://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose.dtd</a>”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1”>
<title>Insert title here</title>
<script language=“JavaScript” type=“text/javascript”>
function showPreview(end) {
if (end != ‘’) {
document.getElementById(‘imagemJogo’).style.display = ‘block’;
document.getElementById(‘imagemJogo’).src = end;
} else document.getElementById(‘imagemJogo’).style.display = ‘none’;
}
function ViewImage(ifile,ix,iy,ititle) {
var win;
var sWidth;
var sHeight;
var NS = (document.layers) ? 1 : 0;
win = window.open("",“imageviewer”,“width=”+ix+",height="+iy+",menubar=no,toolbar=no");
if (NS) {
sWidth = win.innerWidth;
sHeight = win.innerHeight;
} else {
sWidth = win.document.body.clientWidth;
sHeight = win.document.body.clientHeight;
}
if(sWidth!=ix || sHeight!=iy) {
win.close();
setTimeout(“ViewImage(’”+ifile+"’,"+ix+","+iy+",’"+ititle+"’)", 250);
return;
}
win.document.open();
win.document.write("<html><head><title>"+ititle+"</title>");
win.document.write("</head><body>");
win.document.write(’<div style=“position:absolute;width:’+ix+‘px;height:’+iy+'px;left:0px;top:0px”>’);
win.document.write("<img></div></body></html>");
win.document.close();
}
</script>
</head>
<body>
<form action="">
<img>
<b>Imagem:</b><input type=‘file’ name=‘imagemJogo’ id=‘imagemJogo’ onChange=‘showPreview(this.value)’ />
</form>
</body>
</html>