PC6下载站

分类分类

无组件上传图片至SQLSERVER数据库

关注+2004-11-07作者:蓝点

在无组件上传我刚试成功,所以提供代码给大家一起共享


/*  addemployee.asp   */


职工之家






 
   
     
   
   
     
     
   
   
     
     
   
   
     
     
   
   
     
     
   
   
     
     
   
   
     
     
   
 
 

       
标题:

     

       
     

       
分类:

     

       
       
     

       
正文:

     

       
     

       
图片:

     

       

         
       

     
 
       

1、您上传的图片大小请控制在500K以内,否则不允许上传

          2、你上传的图片必须为150*130象素

          3、上传上传图片的格式为JPG或者GIF


     
 
       
  
         

     




*************************************************************************


/* transact1.asp*/



<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
 Dim Fields
 Dim strTitle,strSort,strContent
 Dim rs,sSql
 Dim iMaxid
 Dim strMaxid
 Dim strlen    
 
 Set Fields = GetUpload()
 strTitle=BinaryToString(Fields("txtTitle").value)
 strSort=BinaryToString(Fields("txtSort").value)
 strContent=BinaryToString(Fields("txtContent").value)
 strSort=split(trim(strSort),"-")
 
 if instr(1,lcase(Fields("file").FileName),".jpg")=0 and instr(1,lcase(Fields("file").FileName),".gif")=0 then
    response.write ""
 response.write ""
    Response.end
 end if


 if Fields("file").Length>500000 then
    response.write ""
    response.write ""
 response.end
 end if


 '/*存至数据库*/
     if Fields("file").FileName<>"" then
     Set rs=Server.CreateObject("ADODB.Recordset")
  sSql="select * from employee order by id desc"
  rs.open sSql,conn,2,2
  if not rs.eof  then
           iMaxid=Clng(rs("id"))+1                    
           strlen=4-len(cstr(iMaxid))
           strMaxid=string(strlen,"0") & cstr(iMaxid)  
        else
           strMaxid="0001"                             
        end if
  rs.addnew
        rs("id")=strMaxid
        rs("title")=strTitle
  rs("sort")=strSort(0)
  rs("img").AppendChunk Fields("file").Value
  rs("content")=quoteChg(strContent)
  rs("todate")=date()
        rs.update
        rs.close
        response.write ""
  end if
end if
%>


**********************************************************************
/*fupload.inc*/





展开全部

相关文章

更多+相同厂商

热门推荐

  • 最新排行
  • 最热排行
  • 评分最高
排行榜

    点击查看更多

      点击查看更多

        点击查看更多

        说两句网友评论

          我要评论...
          取消