我上传图片老是说我图像格式不对,不能保存图像(图片格式为jpg), 下面是我的asp 程序,请帮我分析一下,要怎样改才能成功? 我的数据库是用 蔘access2000的,保存图片的字段格式是OLE对象,万分感谢! 一个迷茫的人! <!--#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)
if flgFound = 0 then response.write "<br><br><br><br><p align=center>图片上传成功!是否继续上传?<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
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
rs.addnew fieldsdata,valuesdata set field=rs.fields("photo") field.appendchunk Fields("file"&i).Value
ttt=replace(Fields("file"&i).Value,"'","'") Rs.Update rs.close set rs=nothing else response.write "<script>alert('图像格式不对,不能保存图像');this.location.href='add.asp';</script>" response.End() end if end if next