[英]Read from Blob using Php/Ajax Oracle
I am a newbie to PHP development. 我是PHP开发的新手。 I want to fetch pdf documents stored in a blob column and display them in href
on different pages of my website. 我想获取存储在blob列中的pdf文档,并在我网站的不同页面上的href
显示它们。 But the problem is it shows adobe reader error that says: 但是问题在于它显示Adobe Reader错误,提示:
"The PDF Document cannot be displayed correctly" “ PDF文档无法正确显示”
So far (for the sake of simplicity) I have this: 到目前为止(为简单起见),我有以下内容:
<html>
<head>
<body>
<a href = "readMe.php?id=21">Click here!</a>
</body>
</head>
</html>
PHP code: 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;
?>
Please tell me where I am going wrong? 请告诉我我要去哪里错了?
Don't know why it makes sense, but I replaced the code from: 不知道为什么有意义,但是我替换了以下代码:
while ($rowResult = OCIFetch($stmt))
{
if($rowResult != null){
$a = $rowResult[0];
}
to this: 对此:
while ( $row = OCI_Fetch_Array($stmt, OCI_ASSOC+OCI_RETURN_LOBS) )
{
$a = $row['BLOB_FILE'];
}
Keeping the rest of the code same and now it displays all pdf's in the browser beautifully. 保持其余代码不变,现在它可以在浏览器中漂亮地显示所有pdf。 Chow :) 周:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.