1
Oracle 10gデータベースからBLOBイメージをロードしようとしています。私は.ASP VBと.PHPの両方で試しました。私はそれぞれに以下のメッセージを取得し、両方の例についてはoracle blob imageをPHPまたはASPで表示
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.
dbのblobデータが有効な画像であることを確認してください。 –
はい、バックオフィスではすでに動作しています。バックオフィスはoracle6iフォームにあります。これは、oracleフォームを介してdbaseに格納され、フォームまたはレポートのいずれかで取得されます。 – andreas777
FirebugまたはFiddlerを使用して、サーバーサイドスクリプトからの応答を表示してみてください。そこに問題を指摘する情報があるかもしれません。 –