<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>js判断上传图片大小与高宽_www.jb200.com</title>
<meta name="generator" content="editplus">
<meta name="author" content="">
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<input type="file" onchange="checkimg(this.value)">
</body>
</html>
<script language="
javascript">
<!--
var bb="dd";
bb+="图片";
alert(bb);
function checkimg(path)
{
var img=document.createelement("img");
img.src=path;
if(img.readystate == "complete")
{
var errormsg="";
//判断大小
var fs=img.filesize;
fs=math.round(fs/1024);
alert(img.width+"--"+img.height);
var imgw=img.width;
var imgh=img.height;
if( parseint(imgw)<280 ){ errormsg+= "图片宽度应大于280px,请检查";}
// if(imgh<280){errormsg += "图片高度最少得>=280px,请检查";}
if(fs>140){errormsg+="图片大小不能大于140k";}
if(errormsg!="")
{
alert(errormsg);
return false;
}
else
{
return true;
}
}
else
{
checkimg(path);
}
}
//-->
</script>