来源:网络 | 2007-4-23 | (有2251人读过)
图片存进数据库只能以二进制数据保存,这里即利用AspJpeg的Binary方法,下面以两个AspJpeg用户手册上的代码为例,具体请参考AspJpeg用户手册: Opening Images from Memory <% ’ Using ADO, open database with an image blob strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("../db/aspjpeg.mdb") Set rs = Server.CreateObject("adodb.recordset") SQL = "select image_blob from images2 where id = " & Request("id") rs.Open SQL, strConnect, 1, 3 Set Jpeg = Server.CreateObject("Persits.Jpeg") ’ Open image directly from recordset Jpeg.OpenBinary rs("image_blob").Value ’ Resize jpeg.Width = Request("Width") ’ Set new height, preserve original aspect ratio jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth Jpeg.SendBinary rs.Close %> Output to Memory <% ... Set rs = Server.CreateObject("adodb.recordset") rs.Open "images", strConnect, 1, 3 rs.AddNew rs("image_blob").Value = Jpeg.Binary rs.Update ... %>
|