asp下輕松實現(xiàn)將上傳圖片到數(shù)據(jù)庫的代碼
更新時間:2007年11月24日 22:09:47 作者:
輕松實現(xiàn)將上傳圖片到數(shù)據(jù)庫
很久就想自己寫一寫程序了,不過由于賴就不想寫我,今天剛好有空,所以寫了這個小小的程序很容易一看就知道的,不多說了就此開始:
我們做一個上傳的。數(shù)據(jù)據(jù)庫的字段就id自動編號 big 字段類型是 OLE 呵呵就簡單的那個字段好了
uppic.asp上傳程序名
<%
dim rs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
formsize=request.totalbytes '取得客戶端發(fā)過來的大小
formdata=request.binaryread(formsize)'把客戶發(fā)過來的數(shù)據(jù)轉(zhuǎn)成二進(jìn)制作
bncrlf=chrB(13) & chrB(10)
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
datastart=instrb(formdata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
mydata=midb(formdata,datastart,dataend)'上面總共是取得圖片的二進(jìn)制數(shù)據(jù)
%>
<!--#include file="conn.asp"-->
<%
sql="select * from pic order by id desc"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,2
rs.addnew
rs("big").appendchunk mydata '增加到數(shù)據(jù)庫中
rs.update
set rs=nothing
set conn=nothing
%>
接下來是顯示圖片
display.asp
<!--#include file="conn.asp"--> '這個大家都知道吧,他就是與數(shù)據(jù)庫連的一個程序了
<%
id=request("id")
set rs=server.createobject("ADODB.recordset")
sql="select * from pic where id=" & id
rs.open sql,conn,1,1
Response.ContentType = "text/html" '顯示圖片的格式也可以用
'Response.ContentType = "image/gif" 以gif顯示
'Response.ContentType = "image/jpg" 以jpg顯示
Response.BinaryWrite rs("big") '顯示圖片
rs.close
set rs=nothing
set connGraph=nothing
%>
很久就想自己寫一寫程序了,不過由于賴就不想寫我,今天剛好有空,所以寫了這個小小的程序很容易一看就知道的,不多說了就此開始:
我們做一個上傳的。數(shù)據(jù)據(jù)庫的字段就id自動編號 big 字段類型是 OLE 呵呵就簡單的那個字段好了
uppic.asp上傳程序名
<%
dim rs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
formsize=request.totalbytes '取得客戶端發(fā)過來的大小
formdata=request.binaryread(formsize)'把客戶發(fā)過來的數(shù)據(jù)轉(zhuǎn)成二進(jìn)制作
bncrlf=chrB(13) & chrB(10)
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
datastart=instrb(formdata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
mydata=midb(formdata,datastart,dataend)'上面總共是取得圖片的二進(jìn)制數(shù)據(jù)
%>
<!--#include file="conn.asp"-->
<%
sql="select * from pic order by id desc"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,2
rs.addnew
rs("big").appendchunk mydata '增加到數(shù)據(jù)庫中
rs.update
set rs=nothing
set conn=nothing
%>
接下來是顯示圖片
display.asp
<!--#include file="conn.asp"--> '這個大家都知道吧,他就是與數(shù)據(jù)庫連的一個程序了
<%
id=request("id")
set rs=server.createobject("ADODB.recordset")
sql="select * from pic where id=" & id
rs.open sql,conn,1,1
Response.ContentType = "text/html" '顯示圖片的格式也可以用
'Response.ContentType = "image/gif" 以gif顯示
'Response.ContentType = "image/jpg" 以jpg顯示
Response.BinaryWrite rs("big") '顯示圖片
rs.close
set rs=nothing
set connGraph=nothing
%>
您可能感興趣的文章:
- c#讀取圖像保存到數(shù)據(jù)庫中(數(shù)據(jù)庫保存圖片)
- android創(chuàng)建數(shù)據(jù)庫(SQLite)保存圖片示例
- php上傳圖片到指定位置路徑保存到數(shù)據(jù)庫的具體實現(xiàn)
- android將圖片轉(zhuǎn)換存到數(shù)據(jù)庫再從數(shù)據(jù)庫讀取轉(zhuǎn)換成圖片實現(xiàn)代碼
- Asp.net把圖片存入數(shù)據(jù)庫和讀取圖片的方法
- C#保存圖片到數(shù)據(jù)庫并讀取顯示圖片的方法
- asp.net中上傳圖片文件實現(xiàn)防偽圖片水印并寫入數(shù)據(jù)庫
- ASP.NET下上傳圖片到數(shù)據(jù)庫,并且讀出圖片的代碼(詳細(xì)版)
- asp.net上傳圖片保存到數(shù)據(jù)庫的代碼
- php下將圖片以二進(jìn)制存入mysql數(shù)據(jù)庫中并顯示的實現(xiàn)代碼
- asp.net mvc 從數(shù)據(jù)庫中讀取圖片的實現(xiàn)代碼
- PHP提取數(shù)據(jù)庫內(nèi)容中的圖片地址并循環(huán)輸出
- php 從數(shù)據(jù)庫提取二進(jìn)制圖片的處理代碼
- asp刪除mssql數(shù)據(jù)庫中沒有記錄的圖片代碼
- asp.net 將圖片上傳到mysql數(shù)據(jù)庫的方法
- ASP.Net 圖片存入數(shù)據(jù)庫的實現(xiàn)代碼
- php將數(shù)據(jù)庫中的電話號碼讀取出來并生成圖片
- 上傳圖片后使用數(shù)據(jù)庫保存圖片的示例分享
相關(guān)文章
asp實現(xiàn)批量插入表單中的數(shù)據(jù)到數(shù)據(jù)庫的方法
asp實現(xiàn)批量插入表單中的數(shù)據(jù)到數(shù)據(jù)庫的方法...2007-08-08ASP中用ajax方式獲得session的實現(xiàn)代碼
前期做的時候,登錄方式順手用了ajax來做,登錄前先判斷在session中是否存在值,如果存在,那么無需登錄;如果不存在,那就彈出登錄頁面登錄。2011-05-05使用ASP實現(xiàn)網(wǎng)站的“目錄樹”管理的代碼
使用ASP實現(xiàn)網(wǎng)站的“目錄樹”管理的代碼...2007-09-09利用ASP從遠(yuǎn)程服務(wù)器上接收XML數(shù)據(jù)的方法
利用ASP從遠(yuǎn)程服務(wù)器上接收XML數(shù)據(jù)的方法...2007-01-01