ASP检测图片尺寸

来源:百度知道 编辑:UC知道 时间:2024/05/26 23:24:08
用JS可以检测到图片尺寸.如长*宽.怎么将JS检测出来的数据传送到ASP然后写入数据库.只要长宽的数据.下面是源码:
<script language=javascript>
function hg(){
document.all.thepic.src=document.myform.file1.value;
document.all.picwidth.value = document.all.thepic.width;
document.all.picheight.value = document.all.thepic.height
//alert("上传图片宽度:"+document.all.picwidth.value);
//alert("上传图片高度:"+document.all.picheight.value);
}
</script>
注://alert("上传图片高度:"+document.all.picheight.value);去了"//"时JS可以显示长宽.
<form name="myform" method="post" action="upfile.asp" enctype="multipart/form-data" language="javascript" onsubmit="return check();">
<tr align="center" valign="middle">

<td height="15" align="left">
<img id="thepic" src="" style="visibility:hidden">

<%
imgpath="default_22.gif"

set pp=new imgInfo
w = pp.imgW(server.mappath(imgpath))
h = pp.imgH(server.mappath(imgpath))
set pp=nothing

response.write "<img src='../../"&imgpath&"' border=0><br>宽:"&w&";高:"&h

Class imgInfo
dim aso
Private Sub Class_Initialize
set aso=CreateObject("Adodb.Stream")
aso.Mode=3
aso.Type=1
aso.Open
End Sub
Private Sub Class_Terminate
err.clear
set aso=nothing
End Sub

Private Function Bin2Str(Bin)
Dim I, Str
For I=1 to LenB(Bin)
clow=MidB(Bin,I,1)
if ASCB(clow)<128 then
Str = Str & Chr(ASCB(clow))
else
I=I+1
if I <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow))
end if
Next
Bin2Str = Str
End Function

Private Function Num2Str(num,base,lens)
dim re