hi, i have this script work in FireFox, simetimes in I.E and never in Chrome, i need your help!!!Please...
thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
var Width=200;
// height to resize large images to
var Height=130;
// valid file types
var fileTypes=["bmp","gif","png","jpg","jpeg"];
// the id of the preview image tag
var outImage="previewField";
// what to display when the image is not valid
var defaultPic="spacer.gif";
/***** DO NOT EDIT BELOW *****/
function preview(what){
var source=what.value;
var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
for (var i=0; i<fileTypes.length; i++){
if (fileTypes[i]==ext){
break;
}
}
globalPic=new Image();
if (i<fileTypes.length){
//Obtenemos los datos de la imagen de firefox
try{
globalPic.src=what.files[0].getAsDataURL();
}catch(err){
globalPic.src=source;
}
}else {
globalPic.src=defaultPic;
alert("Esta nao e uma imagem valida:nn"+fileTypes.join(", "));
}
setTimeout("applyChanges()",200);
}
var globalPic;
function applyChanges(){
var field=document.getElementById(outImage);
var x=parseInt(globalPic.width);
var y=parseInt(globalPic.height);
if (x>Width) {
y*=Width/x;
x=Width;
}
if (y>Height) {
x*=Height/y;
y=Height;
}
field.style.display=(x<1 || y<1)?"none":"";
field.src=globalPic.src;
field.width=x;
field.height=y;
}
// End -->
</script>
</head>
<body>
<tr>
<td rowspan="4" align="center"><img border="1px" width="180" height="130" alt="" id="previewField" align="middle" src="" /></td>
<td align="center"><input name="arquivo" type="file" id="picField" style="" onChange="preview(this)" size="1"></td>
</tr>
</body>
</html>