欢迎光临
我们一直在努力

苦心源码,欢迎下载

建站超值云服务器,限时71元/月

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(tempstr,tstr,0)=0 then
      msgstr05="png"
        
      i_width  = lngconvert2(midb(checkdata, 19, 2))
      i_height = lngconvert2(midb(checkdata, 23, 2))
      i_depth  = lngconvert(midb(checkdata, 25, 2))

      select case ascb(right(i_depth,1))
        case 0
          i_depth   = 2 ^ (asc(left(i_depth, 1)))
          gfxspex = true
        case 2
          i_depth   = 2 ^ (asc(left(i_depth, 1)) * 3)
          gfxspex = true
        case 3
          i_depth   = 2 ^ (asc(left(i_depth, 1))) 8
          gfxspex = true
        case 4
          i_depth   = 2 ^ (asc(left(i_depth, 1)) * 2)
          gfxspex = true
        case 6
          i_depth   = 2 ^ (asc(left(i_depth, 1)) * 4)
          gfxspex = true
        case else
          i_depth   = -1
      end select
      msgstr06=","& i_height & ","& i_width

      flag=2
    else
      flag=0
    end if
  end if
  if flag=0 then
     msgstr07="no image"
  end if
  msgstr=msgstr01 & msgstr02 & msgstr03 & msgstr04 & msgstr05 & msgstr06 & msgstr07

  checkimageformat=msgstr
end function

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

————————copyright by qinls——————
%>

<%

response.buffer=true                   将服务端传送给缓冲区
filesize=request.totalbytes               客户端响应数据字节的大小
filedata=request.binaryread(filesize)  得到数据量要小于或等于totalbytes

*******得到有效的图片的信息*********
bncrlf=chrb(13) & chrb(10)
divider=leftb(filedata,clng(instrb(filedata,bncrlf))-1)
datastart=instrb(filedata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,filedata,divider)-datastart   (搜索的起点,字符串1,字符串2)
mydata=midb(filedata,datastart,dataend)

arraymessage=split(checkimageformat(mydata),",")
*********************************

%>

<% if arraymessage(1)>150 or arraymessage(2)>100 then %>   
   <script language="javascript">
         alert("您所选择的图片的尺寸不符合要求!应在 高*宽 150*100 之间")
         window.location="sp.htm"
   </script>
<% else
set cn=server.createobject("adodb.connection")
cn.connectionstring="driver={microsoft access driver (*.mdb)};dbq=" & server.mappath("pic.mdb")
cn.open

set rs=server.createobject("adodb.recordset")
rs.open "select * from t1 where id is null",cn,1,3
rs.addnew
rs.fields("img").appendchunk mydata
rs.update
rs.close
set rs=nothing
set cn=nothing
end if
%>
<script language="javascript">
   window.location="sp.htm"
</script>

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

searchpic.asp

<script language="javascript">

</script>
<%
set cn=server.createobject("adodb.connection")
cn.connectionstring="driver={microsoft access driver (*.mdb)};dbq=" & server.mappath("pic.mdb")
cn.open
set rs=server.createobject("adodb.recordset")

sql="select * from t1"
rs.open sql,cn,2,3

response.write "<table width=""100%"" cellspacing=""0"" cellpadding=""0"" border=""2"" bordercolor=""#cccccc"" align=""center"">"
do while not rs.eof
   response.write "<tr>"
   response.write "<td>"
   response.write trim(rs.fields("id"))
   response.write "</td>"
   numberimg=rs.fields("id")
   response.write "<td>"
   response.write "<img src=""showpic.asp?id=" & numberimg & """>"
   response.write "</td>"
   rs.movenext
   response.write "</tr>"
loop
   response.write "</table>"%>
<% response.write "<p></p>" %>
<input type="button" value="继续上传图片"  onclick="window.location=sp.htm">
<%rs.close
cn.close
%>

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
seebig.asp

<html>
<body >
<input type="image" name="img1" src= <%=request("fff") %> >
</body>
</html>

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

showpic.asp

<%
set cn=server.createobject("adodb.connection")
cn.connectionstring="driver={microsoft access driver (*.mdb)};dbq=" & server.mappath("pic.mdb")
cn.open
set rs=server.createobject("adodb.recordset")
sql="select img from t1 where id=" & request("id")
rs.open sql,cn,1,1
response.contenttype = "image/*"
response.binarywrite rs("img").getchunk(7500000)

rs.close

set rs=nothing
set cn=nothing
%>

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

sp.htm

<html>
<head>
<script language="javascript">
    function see(hh,ff) {
        hh.src=ff.value
}
    function seebig(filepath){
        window.open("seebig.asp?fff="+filepath,"","");
}
</script>
</head>
<body>

<form name="f1" enctype="multipart/form-data" action="savepic.asp" method=post>
  <input type=file name="file1">
  <input type="button" name="b1" value="预览" onclick="see(this.form.picview,this.form.file1)" >
  <input type=submit name="upfile" value="上传">
  <br>
<img src="image/view.jpg" name="picview" width="100" height="120" border="0" alt="单击放大" onclick="seebig(file1.value)">
</form>

<form name="f2" action="searchpic.asp" method="post">
  <input type="submit" name="s2" value="查看所有上传图片">
</form>

</body>
</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 苦心源码,欢迎下载
分享到: 更多 (0)