使用Php/ajaxoracle从Blob读取
我是PHP开发的新手。我想获取存储在blob列中的pdf文档,并将它们显示在我网站的不同页面上的使用Php/ajaxoracle从Blob读取,php,ajax,oracle,pdf,blob,Php,Ajax,Oracle,Pdf,Blob,我是PHP开发的新手。我想获取存储在blob列中的pdf文档,并将它们显示在我网站的不同页面上的href。但问题是它显示了adobe reader的错误,即: “无法正确显示PDF文档” 到目前为止(为了简单起见),我有以下几点: <html> <head> <body> <a href = "readMe.php?id=21">Click here!</a> </body> </head> </ht
href
。但问题是它显示了adobe reader的错误,即:
“无法正确显示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。周:)