Я пытаюсь загрузить образ BLOB-объекта из базы данных Oracle 10g. Я пробовал и в .ASP VB и .PHP.
TABLE = STD_IMAGE
Name Null? Type
------------------------------- -------- ----
IMG_ID_NO NOT NULL NUMBER(10)
IMG_IMAGE NOT NULL BLOB
ASP код
<%@ LANGUAGE="VBSCRIPT" %>
<%Option Explicit
Dim Rs, sSQL, OBJdbConnection
' Clear out the existing HTTP header information
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
'Change the HTTP header to reflect that an image is being passed.
Response.ContentType = "image/jpg"
Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.Open "Provider=OraOLEDB.Oracle;Data Source=xxxxxx;User Id=xxxx;Password=xxxxx;"
DIM itemID
itemID = request.querystring("InventoryItemId")
itemID = 25
sSQL = "Select * from std_image where IMG_ID_NO=25"
set rs = OBJdbConnection.Execute(sSql)
If not rs.eof Then
Response.BinaryWrite rs("IMG_IMAGE")
Response.End
End If
CloseRecordset(rs)%>
<%Set OBJDbConnection = nothing%>
Код PHP
<?php
$db ="(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = xxxxxx)
(PORT = 1522)
)
(CONNECT_DATA = (SID = xxxxx))
)";
$odbc = ocilogon ('xxxxxx', 'xxxxxx', $db) or die( "Could not connect to Oracle database!") or die (ocierror());
$sql = "SELECT IMG_IMAGE FROM std_image WHERE IMG_ID_NO = 25";
$stid = ociparse($odbc, $sql);
ociexecute($stid);
$row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS);
if (!$row) {
header('Status: 404 Not Found');
} else {
$img = $row['IMG_IMAGE']->load();
header("Content-type: image/jpg");
print $img;
}
?>
Для обоих примеров я получаю следующие сообщения для каждого:
The image “http://localhost/test_ShowImage.asp” cannot be displayed because it contains errors.
The image “http://localhost/test_getImage.php” cannot be displayed because it contains errors.