使用Php/Ajax Oracle从Blob中读取


Read from Blob using Php/Ajax Oracle

我是PHP开发的新手。我想获取存储在blob列中的pdf文档,并将它们显示在我网站的不同页面上的href中。但问题是它显示了adobe阅读器错误,上面写着:

"PDF文档无法正确显示"

到目前为止(为了简单起见)我有这个:

<html>
<head>
<body>
<a href = "readMe.php?id=21">Click here!</a>
</body> 
</head>
</html>

PHP代码:

<?php
session_start();
$id = $_GET[id];
$conn = OCILogon("abc","abc","abcserver");
$qry = "select blob_file,doc_name from doc_data where ID =".$id;
$stmt = ociparse ($conn,$qry);
OCIDefineByName($stmt,"BLOB_FILE",$blobFile);
OCIDefineByName($stmt,"DOC_NAME",$blobFileName);
OCIExecute($stmt);
while ($rowResult = OCIFetch($stmt))
{
if($rowResult != null){
$a = $rowResult[0];
}
}
header('Content-type: application/pdf'); 
header('Content-disposition: inline;filename='.$blobFileName.'.pdf'); 
echo $a;
?>

请告诉我哪里出了问题?

不知道为什么它有意义,但我替换了以下代码:

while ($rowResult = OCIFetch($stmt))
{
if($rowResult != null){
$a = $rowResult[0];
}

到此:

while ( $row = OCI_Fetch_Array($stmt, OCI_ASSOC+OCI_RETURN_LOBS) ) 
{
$a = $row['BLOB_FILE'];
}

保持其余代码不变,现在它在浏览器中漂亮地显示了所有pdf。Chow:)