Upload the image to the database

xiaoxiao2021-03-06  100

Upload the picture to the database [2004-4-28] [Form Web] √ invisible ☆☆☆☆

The code is as follows: upload.htm 'Upload page

get.asp 'Handling Data sent from the browser <% response.buffer = trueformsize = request.totalbytes formData = request.binaryRead (Formsize) 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) set conn = server.createObject ("adoDb.connection") conn.connectionstring = "driver = {Microsoft Access Driver (* .mdb)}; dbq =" & Server.mappath ("Images .mdb ") Conn.CreateObject (" AdoDb.Recordset ") rs.open" Select * from [images] where id is null ", conn, 1, 3 rs.addNew RS (" IMG ") .appendchunk mydata rs.Update rs.close set = nothing set conn = Nothing%> showi Mg.asp 'Display Image <% SET CONN = Server.createObject ("AdoDb.Connection" Conn.connectionstring = "Driver = {Microsoft Access Driver (* .mdb)}; dbq =" & Server.mappath ("Images. MDB ") Conn.open set RS = Server.createObject (" AdoDb.Recordset ") strsql =" select img from images where id = "& trim (Request (" ID ")) RS.Open Strsql, CONN, 1, 1 Response.contentType = "image / *" '

Before outputting to the browser, you must specify response.contentType = "image / *" to normalize image response.binaryWrite Rec ("img"). GetChunk (7500000) RS.Close Set RS = Nothing set conn = nothing%> The database structure is as follows: Access: Sequence field name Type Description 1ID Auto Number Main key value 2IMGOLE object is used to save image data MS SQL Server:

Serial No. Field Name Type Description 1IDINT (Identity) Primary key value 2Imgimage is used to save image data

© 2004 hsdn. All Rights Reserved. 锲 锲 不, Jinshi Ke

转载请注明原文地址:https://www.9cbs.com/read-124386.html

New Post(0)