答案:该方法是通过读取jpg文件头来判断JPG图像的尺寸
<html>
<body>
<form action="up.asp" ENCTYPE="multipart/form-data" method="post">
<table border=0 width=100% cellspacing="0">
<tr>
<td width="30%">请选择您要上传的jpg图片:</td>
<td width="70%"><input type="file" name="pic" style="font-size:10pt;"></td>
</tr>
</table>
<p align="center"><input type="submit" value="提交">
</form>
</body>
</html>
<%
FormSize = Request.TotalBytes
FormData = Request.BinaryRead( FormSize )
bncrlf=chrb(13) & chrb(10)
divider=leftb(formdata,instrb(formdata,bncrlf)-1)
datastart=instrb(formdata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
Image=midb(formdata,datastart,dataend)
head_height_l = Ascb( midb( Image,165,1 ) )
head_height_h = Ascb( midb( Image,164,1 ) )
head_width_l = Ascb( midb( Image,167,1 ) )
head_width_h = Ascb( midb( Image,166,1 ) )
head_width_h = head_width_h * 256
head_height_h = head_height_h * 256
Response.Write "图像大小为" & head_width_h + head_width_l & "x" & head_height_h + head_height_l
%>
上一个:ASP获取来访IP(只用一句)
下一个:ASP随机图片显示代码