SavePic.asp
<%
'---------------------------------------RETURN THE IMAGE FORMAT--------------------
function checkImageFormat(checkdata)
'--return: A,B,C (A is image format; B is height pixels; C is width pixels; D is color depth)
flag=0 '''''''0 is not jpg/gif/png image; 1 is jpg/gif/png
'-------------------------------------------------------check jpg----------------
if flag=0 then
tempstr=Leftb(checkdata,10)
tstr=chrb(255)&chrb(216)&chrb(255)&chrb(224)&chrb(0)&chrb(16)&chrb(74)&chrb(70)&chrb(73)&chrb(70)
if strcomp(tempstr,tstr,0)=0 then
msgstr01="jpg"
lngSize = len(checkdata)
flgFound = 0
strTarget = chrb(255) & chrb(216) & chrb(255)
flgFound = instrb(checkdata, strTarget)
lngPos = flgFound + 2
ExitLoop = false
do while ExitLoop = False and lngPos < lngSize
do while ascb(midb(checkdata, lngPos, 1)) = 255 and lngPos < lngSize
lngPos = lngPos + 1
loop
if ascb(midb(checkdata, lngPos, 1)) < 192 or ascb(midb(checkdata, lngPos, 1)) > 195 then
lngMarkerSize = lngConvert2(midb(checkdata, lngPos + 1, 2))
lngPos = lngPos + lngMarkerSize + 1
else
ExitLoop = True
end if
loop
i_Height = lngConvert2(midb(checkdata, lngPos +4, 2))
i_Width = lngConvert2(midb(checkdata, lngPos +6, 2))
i_Depth = 2 ^ (ascb(midb(checkdata, lngPos + 8, 1)) * 8)
msgstr02=","& i_height & "," & i_width
flag=2
else
flag=0
end if
end if
'--------------------------------------------------check gif--------------------------------
if flag=0 then
tempstr=Leftb(checkdata,6)
tstr=chrb(71)&chrb(73)&chrb(70)&chrb(56)&chrb(57)&chrb(97)
tstr2=chrb(71)&chrb(73)&chrb(70)&chrb(56)&chrb(55)&chrb(97)
if strcomp(tempstr,tstr,0)=0 or strcomp(tempstr,tstr2)=0 then
msgstr03="gif"
i_width=lngConvert(midb(checkdata,7,2))
i_height=lngConvert(midb(checkdata,9,2))
i_Depth = 2 ^ ((ascb(midb(checkdata, 11, 1)) and 7) + 1)
msgstr04=","& i_height & ","& i_width
flag=2
else
flag=0
end if
end if
'---------------------------------------------------check png------------------------------
if flag=0 then
tempstr=Leftb(checkdata,4)
tstr=chrb(137)&chrb(80)&chrb(78)&chrb(71)
if strcomp(temp