js如何获取上传图片的大小

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script>
function func()
{
var oImg=new Image();
var iFlag=false;
oImg.onload=function()
{
if(!iFlag)
{
iFlag=true;
alert("width:"+oImg.width+"\nheight:"+oImg.height+"\nfilesize:"+(oImg.fileSize/1024).toFixed(1)+"k");
}
}
oImg.src=myform1.file1.value;
}
</script>
</head>
<body>
<table width="50%" valign="botom" height="22" border="1">
<!--存在两个不同表单所以需要不同的名字-->
<form method="post" name="myform1" enctype="multipart/form-data">
<tr>
<td>
<input type="file" name="file1" size="20" onchange="func()" />
</td>
</td>
</tr>
</form>
</table>
</body>
</html>

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/langzi1105/archive/2009/04/28/4131873.aspx

你可能感兴趣的:(html,.net,Blog)