asp下輕松實(shí)現(xiàn)將上傳圖片到數(shù)據(jù)庫(kù)的代碼
更新時(shí)間:2007年11月24日 22:09:47 作者:
輕松實(shí)現(xiàn)將上傳圖片到數(shù)據(jù)庫(kù)
很久就想自己寫(xiě)一寫(xiě)程序了,不過(guò)由于賴就不想寫(xiě)我,今天剛好有空,所以寫(xiě)了這個(gè)小小的程序很容易一看就知道的,不多說(shuō)了就此開(kāi)始:
我們做一個(gè)上傳的。數(shù)據(jù)據(jù)庫(kù)的字段就id自動(dòng)編號(hào) big 字段類型是 OLE 呵呵就簡(jiǎn)單的那個(gè)字段好了
uppic.asp上傳程序名
<%
dim rs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
formsize=request.totalbytes '取得客戶端發(fā)過(guò)來(lái)的大小
formdata=request.binaryread(formsize)'把客戶發(fā)過(guò)來(lái)的數(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ù)庫(kù)中
rs.update
set rs=nothing
set conn=nothing
%>
接下來(lái)是顯示圖片
display.asp
<!--#include file="conn.asp"--> '這個(gè)大家都知道吧,他就是與數(shù)據(jù)庫(kù)連的一個(gè)程序了
<%
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
%>
很久就想自己寫(xiě)一寫(xiě)程序了,不過(guò)由于賴就不想寫(xiě)我,今天剛好有空,所以寫(xiě)了這個(gè)小小的程序很容易一看就知道的,不多說(shuō)了就此開(kāi)始:
我們做一個(gè)上傳的。數(shù)據(jù)據(jù)庫(kù)的字段就id自動(dòng)編號(hào) big 字段類型是 OLE 呵呵就簡(jiǎn)單的那個(gè)字段好了
uppic.asp上傳程序名
<%
dim rs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
formsize=request.totalbytes '取得客戶端發(fā)過(guò)來(lái)的大小
formdata=request.binaryread(formsize)'把客戶發(fā)過(guò)來(lái)的數(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ù)庫(kù)中
rs.update
set rs=nothing
set conn=nothing
%>
接下來(lái)是顯示圖片
display.asp
<!--#include file="conn.asp"--> '這個(gè)大家都知道吧,他就是與數(shù)據(jù)庫(kù)連的一個(gè)程序了
<%
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ù)庫(kù)中(數(shù)據(jù)庫(kù)保存圖片)
- android創(chuàng)建數(shù)據(jù)庫(kù)(SQLite)保存圖片示例
- php上傳圖片到指定位置路徑保存到數(shù)據(jù)庫(kù)的具體實(shí)現(xiàn)
- android將圖片轉(zhuǎn)換存到數(shù)據(jù)庫(kù)再?gòu)臄?shù)據(jù)庫(kù)讀取轉(zhuǎn)換成圖片實(shí)現(xiàn)代碼
- Asp.net把圖片存入數(shù)據(jù)庫(kù)和讀取圖片的方法
- C#保存圖片到數(shù)據(jù)庫(kù)并讀取顯示圖片的方法
- asp.net中上傳圖片文件實(shí)現(xiàn)防偽圖片水印并寫(xiě)入數(shù)據(jù)庫(kù)
- ASP.NET下上傳圖片到數(shù)據(jù)庫(kù),并且讀出圖片的代碼(詳細(xì)版)
- asp.net上傳圖片保存到數(shù)據(jù)庫(kù)的代碼
- php下將圖片以二進(jìn)制存入mysql數(shù)據(jù)庫(kù)中并顯示的實(shí)現(xiàn)代碼
- asp.net mvc 從數(shù)據(jù)庫(kù)中讀取圖片的實(shí)現(xiàn)代碼
- PHP提取數(shù)據(jù)庫(kù)內(nèi)容中的圖片地址并循環(huán)輸出
- php 從數(shù)據(jù)庫(kù)提取二進(jìn)制圖片的處理代碼
- asp刪除mssql數(shù)據(jù)庫(kù)中沒(méi)有記錄的圖片代碼
- asp.net 將圖片上傳到mysql數(shù)據(jù)庫(kù)的方法
- ASP.Net 圖片存入數(shù)據(jù)庫(kù)的實(shí)現(xiàn)代碼
- php將數(shù)據(jù)庫(kù)中的電話號(hào)碼讀取出來(lái)并生成圖片
- 上傳圖片后使用數(shù)據(jù)庫(kù)保存圖片的示例分享
相關(guān)文章
asp實(shí)現(xiàn)批量插入表單中的數(shù)據(jù)到數(shù)據(jù)庫(kù)的方法
asp實(shí)現(xiàn)批量插入表單中的數(shù)據(jù)到數(shù)據(jù)庫(kù)的方法...2007-08-08ASP中用ajax方式獲得session的實(shí)現(xiàn)代碼
前期做的時(shí)候,登錄方式順手用了ajax來(lái)做,登錄前先判斷在session中是否存在值,如果存在,那么無(wú)需登錄;如果不存在,那就彈出登錄頁(yè)面登錄。2011-05-05isnumeric檢測(cè)是否為數(shù)字類型的asp代碼
ASP判斷是否為數(shù)字通常用isnumeric()函數(shù),它的作用是判斷里面的參數(shù)表達(dá)式是不是數(shù)值2007-11-11使用ASP實(shí)現(xiàn)網(wǎng)站的“目錄樹(shù)”管理的代碼
使用ASP實(shí)現(xiàn)網(wǎng)站的“目錄樹(shù)”管理的代碼...2007-09-09利用ASP從遠(yuǎn)程服務(wù)器上接收XML數(shù)據(jù)的方法
利用ASP從遠(yuǎn)程服務(wù)器上接收XML數(shù)據(jù)的方法...2007-01-01