javascript判断上传图片的大小和格式
2008-11-05 20:00:10 来源:WEB开发网<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Author" CONTENT="宝玉">
</HEAD>
<script language="javascript">
www.phperz.com
<!--
//检查插入是否为图片
var img=null;
function chkimg(inp)
{
if(img)img.removeNode(true);
img=document.createElement("img");
img.attachEvent("onreadystatechange",isimg);
img.attachEvent("onerror",notimg);
img.src=inp;
}
function notimg()
{
alert("您插入的不是图片,请重新选择插入");
}
function isimg()
phperz.com
{
show.insertAdjacentElement("BeforeEnd",img);
show1.innerHTML = "图片大小"+ img.fileSize/1024+"K<br/>图片宽度"+img.offsetWidth+"<br/>图片高度"+img.offsetHeight;
}
// -->
</script>
<BODY>
<div id="show"></div>
<div id="show1"></div>
<input type="file" name="" onPRopertychange="chkimg(this.value)"/>
</BODY>
</HTML>
Tags:javascript 判断 上传
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接