华晨中华v3多少钱:分析一段代码asp中图片上传到数据库中?

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 04:20:16
这段代码是图片以二进制输入acsess中
哪位大哥能具体的帮我看一下,好多代码都不懂,而且这个只能上传gif格式的图片,jpg的不能,不知道什么原因?

<!--#include file="conn.asp"-->
<!--#INCLUDE FILE="upload.inc"-->
<%
function lngConvert2(strTemp)
str1=leftb(strTemp,1)
str2=rightb(strTemp,1)
lngConvert2 = clng(ascb(str2) + ((ascb(str1) * 256)))
end function

function lngConvert(strTemp)
str1=leftb(strTemp,1)
str2=rightb(strTemp,1)
len1=ascb(str1)
len2=ascb(str2)
lngConvert = clng(ascb(str1) + ascb(str2) * 256)
end function

Dim FormData,FormSize
FormSize=Request.TotalBytes
FormData=Request.BinaryRead(FormSize)
Set Fields = GetUpload(FormData)

for i=1 to 5 '获得图片的宽度和高度
If Fields("file"&i).FileName<>"" and Fields("file"&i).value<>"" Then
tempstr=Leftb(Fields("file"&i).Value,10)
tstr=chrb(255)&chrb(216)&chrb(255)&chrb(224)&chrb(0)&chrb(16)&chrb(74)&chrb(70)&chrb(73)&chrb(70)

flag=1
if strcomp(tempstr,tstr,0)=0 then

lngSize = len(fields("file"&i).value)
flgFound = 0

strTarget = chrb(255) & chrb(216) & chrb(255) 'JPG
flgFound = instrb(fields("file"&i).value, strTarget)

if flgFound = 0 then
response.write "<br><br><br><br><p align=center>图片上传有可能错误!是否继续上传?<br><Br>(图像也许没有经过处理)<br><br><br>"
response.write "<a href='add.asp' title='继续上传'><font color='#000000'>是</font></a><font color='#FFFFFF'>图片上传</font><a href='manage.asp' title='返回图片管理'><font color='#000000'>否</font></a>"
response.end
end if

strImageType = "JPG"
lngPos = flgFound + 2
ExitLoop = false

do while ExitLoop = False and lngPos < lngSize

do while ascb(midb(fields("file"&i).value, lngPos, 1)) = 255 and lngPos < lngSize
lngPos = lngPos + 1
loop

if ascb(midb(fields("file"&i).value, lngPos, 1)) < 192 or ascb(midb(fields("file"&i).value, lngPos, 1)) > 195 then
lngMarkerSize = lngConvert2(midb(fields("file"&i).value, lngPos + 1, 2))
lngPos = lngPos + lngMarkerSize + 1
else
ExitLoop = True
end if

loop

height = lngConvert2(midb(fields("file"&i).value, lngPos +4, 2))
width = lngConvert2(midb(fields("file"&i).value, lngPos +6, 2))
flag=2
else
flag=0
end if

if flag<>2 then
tempstr=Leftb(Fields("file"&i).Value,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
width=lngConvert(midb(fields("file"&i).value,7,2))
height=lngConvert(midb(fields("file"&i).value,9,2))
flag=2
else
flag=0
end if
end if

if flag<>2 then
tempstr=Leftb(Fields("file"&i).Value,2)
tstr=chrb(66)&chrb(77) 'BMP
if strcomp(tempstr,tstr,0)=0 then

width=lngConvert(midb(fields("file"&i).value,19,2))
height=lngConvert(midb(fields("file"&i).value,23,2))

flag=2
else
flag=0
end if
end if

到网上下载一个其它的上传插件不就可以了吗?
呵~有许多无组件上传的程序哦!