Reputation: 6605
i am utilizing aspSmartUpload to upload an image into an Oracle BLOB field, see below:
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
when i check the db table. attach_data is populated. now. when i try to read the image back, i keep getting "Response object: 007~ASP 0106~Type Mismatch~An unhandled data type was encountered." error on the BinaryWrite. please help!
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
Upvotes: 1
Views: 907
Reputation: 1247
Images should be stored as BLOB data (Binary Large Object) in Oracle, not CLOB (Character Large Object).
Upvotes: 2