DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: snarv12
今日帖子: 0
在线用户: 12
导航: 论坛 -> 网站意见 斑竹:zizii,sunyesy  
作者:
男 cwl198 (jack) ★☆☆☆☆ -
普通会员
2003/9/30 13:48:26
标题:
请教站长!! 浏览:2383
加入我的收藏
楼主: 我上传图片老是说我图像格式不对,不能保存图像(图片格式为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)
  
  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>"
      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
  
  if flag<>2 then 
    tempstr=Leftb(Fields("file"&i).Value,4)
    tstr=chrb(137)&chrb(80)&chrb(78)&chrb(71) 'PNG
    if strcomp(tempstr,tstr,0)=0 then
    
      width = lngConvert2(midb(fields("file"&i).value, 19, 2))
      height = lngConvert2(midb(fields("file"&i).value, 23, 2))
      
      flag=2
    else 
      flag=0
    end if
  end if
  
  
  if flag>0 then
    Set rs = Server.CreateObject("ADODB.Recordset")
    sql="select * from imgbook"
    rs.open sql,conn,1,3
    
    fieldsdata=Array("title","content","updatetime","classname","tuijie","width","height","photo")
    valuesdata=Array(Fields("title").Value,Fields("guestcontent").Value,now,Fields("classname").value,Fields("tuijie").value,width,height,"")
    
    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

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
conn.close
set conn=nothing
%>
----------------------------------------------
-
作者:
男 zizii (高高高级馒头) ★☆☆☆☆ -
神秘会员
2003/10/9 9:05:54
1楼: 没做过,不清楚。
----------------------------------------------
维护世界和平,共创美好盒子。
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行58.59375毫秒 RSS