孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
1.upload.asp方法
<head>
<script language=vbscript>
    function checkinfo()
       if (document1.form1.picture.value<>"") then
         if (Instr(1,document.form1.picture.value,".")<=0) or (Instr(1,document.form1.picture.value,"\")<=0)  or ((Instr(1,document.form1.picture.value,"bmp")<=0) and (Instr(1,document.form1.picture.value,"gif")<=0) and  (Instr(1,document.form1.picture.value,"jpg")<=0)) then
            msgbox('图片格式不正确,请重写!')
            document.form1.picture.focus()
            document.form1.picture.select(this)
            window.even.returnvalue=false
            exit function
          end if    
          form2.submit
          if document.form1.picture1.value<>" " then
            form1.submit
          end if
     end function   
</script>
</head>
<form name="form1" ENCTYPE="multiport/form-data" Action="upimage.asp" Method="POST" target="_blank">
  新闻图片:<input name="picture" TYPE="file" size=40>
</form>
<form method="POST" action="uptext.asp" name="form2" target="_blank">新闻内容:
<input name="text" type="text" size=40>
<p><input type="button" value="提交" name="B1" onclick="checkinfo()">
<input type="reset" value="清除" name="B2">

2.上传文本页面
<%
  text=request("text")
  set rs=Server.CreateObject("ADODB.Recordset")
  sql="select * from newtable2"
  rs.Open sql,conn,1,3
  rs.AddNew
  rs.("text")=text
  rs.Update
  rs.Close
  response.write text
%>
<p align="center"><a href="javascript.Close()">关闭窗口</a></p>

3.上传图像页面
注:用rs的appendchunk方法存储图像
<%
  FormSize=Request.TotalBytes
  FormData=Request.BinaryRead(FormSize)
  function ImageUp(formsize,formdata)
    bnctrf=chrb(13) & chrb(10)
    divider=leftb(formdata,instrb(formdata,bnctrf)-1)
    datastart=instrb(formdata,bnctrf & bnctrf)+4
    dataend=instrb(formdata,datastart,dataend)
  end function
  Image=ImageUp(FormSize,FormData)
  set rs=Server.Create("adodb.recordset")
%>
<#include file="data.inc"-->
<%
  sql="select top 1 * from newstable2 order by id desc"
  rs.open sql.conn,1,3
  rs("picture").appendchunk Image
  re.Update
%>
<img src=showimg.asp>id=<%=rs("id")%>>
<%
  rs.Close
%>
posted on 2008-09-20 21:52  孤独的猫  阅读(203)  评论(0编辑  收藏  举报