img js
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<script language="JavaScript">
function trim(str)
{
regExp1 = /^ */;
regExp2 = / *$/;
return str.replace(regExp1,'').replace(regExp2,'');
}
var i=0;
function show(){
// document.Form1.UploadFileBox.value = trim(document.Form1.UploadFileBox.value);
var showimg = new Image();
showimg.src = document.getElementById("uploadFileBox").value;
if(showimg.width >400)
{
alert("the pic width >400");
return false;
}
document.getElementById("preview").src = document.getElementById("UploadFileBox").value;
if(showimg.width >= 200){
var ori_w= showimg.width;
var ori_h = showimg.height;
showimg.width = 200;
showimg.height = ori_h * showimg.width / ori_w;
} else {
if(showimg.height >= 200){
var ori_w2= showimg.width;
var ori_h2 = showimg.height;
showimg.height = 200;
showimg.width = ori_w2 * showimg.height / ori_h2;
} else{
showimg.height = showimg.height;
showimg.width = showimg.width;
}
}
document.all.preview.style.width = showimg.width;
document.all.preview.style.height = showimg.height;
}
</script>
<body>
<form name="Form1" method="post" action="UploadImage.aspx?classid=1" id="Form1" enctype="multipart/form-data">
............
<TD><input name="UploadFileBox" id="UploadFileBox" type="file" style="WIDTH: 352px; HEIGHT: 22px" size="39" onpropertychange ="show()" ></TD>
............
</form>
<img src="aaa.gif" id="preview" height="200" width=400>
</body>
</html>