保存和读取Oracle中的图像与我正在利用aspSmartUpload上传图片到Oracle BLOB字段传统的ASP
问题描述:
,见下图:保存和读取Oracle中的图像与我正在利用aspSmartUpload上传图片到Oracle BLOB字段传统的ASP
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
'*** Upload Files ***'
mySmartUpload.Upload
set file = mySmartUpload.Files("file1")
Set MyConn = Server.CreateObject("ADODB.Connection")
Call OpenConnect(MyConn)
sql = "SELECT attach_data, title, idx, attach_type_id FROM c_attachment"
Set Rs = Server.CreateObject("ADODB.recordset")
Set rs.ActiveConnection = MyConn
rs.Source = sql
rs.CursorLocation = 3
rs.CursorType = 0
rs.LockType = 3
rs.Open sql
If not file.IsMissing Then 'Check for missing file
'Add the current file in database
Rs.AddNew
file.FileToField Rs.Fields("attach_data")
Rs("title") = "title test"
rs("idx") = "134774"
rs("attach_type_id") = 1
Rs.Update
rs.Close
set rs = nothing
End If
当我检查db表。 attach_data被填充。现在。当我尝试读取图像时,我不断收到“响应对象:007〜ASP 0106〜类型不匹配〜遇到未处理的数据类型”。 BinaryWrite错误。请帮忙!
Set MyConn = Server.CreateObject("ADODB.Connection")
Call OpenConnect(MyConn)
SQLQuery = "select attach_data,title from c_attachment where attach_id = 109"
Set RSList = MyConn.Execute(SQLQuery)
If RSList.EOF Then
blnImgExists = False
Else
FileData = RSList("attach_data")
blnImgExists = true
End If
if blnImgExists Then
Response.Clear
Response.ContentType = "image/jpeg"
Response.AddHeader "Content-disposition", "attachment; filename=image.jpg"
Response.BinaryWrite RSList("attach_data")
else
response.write "count not open"
end if
答
图像应该存储为Oracle中的BLOB数据(二进制大对象),而不是CLOB(字符大对象)。
只是为了澄清,图像将被存储为BLOB而非CLOB。该列是BLOB吗? – REW
哇。我不敢相信我做到了。谢谢!我会把它作为答案,如果你回答我的问题:) –
@REW只是戳。 –