如何使用PHP从blob oracle下载PDF文件?

如何使用PHP从blob oracle下载PDF文件?,php,oracle,Php,Oracle,我想从oracle下载blob文件,即PDF文件,这是我获取和下载文件的代码: <?php $conn = ocilogon('user', 'pass', '//localhost/XE'); $sql = "SELECT PDFFILE FROM TFILE"; $stid = ociparse($conn,$sql); ociexecute($stid); $rowResult = ocifetch($stid); settype($arrayResu

我想从oracle下载blob文件,即PDF文件,这是我获取和下载文件的代码:

<?php
$conn = ocilogon('user', 'pass', '//localhost/XE');
$sql = "SELECT PDFFILE FROM TFILE";
    $stid = ociparse($conn,$sql);
    ociexecute($stid);
    $rowResult = ocifetch($stid);
    settype($arrayResult,"array");
if($rowResult != null){
            header("Content-Type: application/octet-stream");
            header('Content-Disposition: attachment; filename="' . OCIResult($stid,'PDFFILE') . '"');    
            header("Content-Length: " . filesize(OCIResult($stid,'PDFFILE')->load()));
            header('Content-Disposition: attachment; header("Content-Transfer-Encoding: binary\n");
    }
    ?>


您将发送两次
内容处置
标题。您甚至可能不需要第二个,客户机应该从
内容类型
头中了解它需要了解的关于流的所有信息。省略第二个
内容配置
,这样您就不会过度写入包含文件名的标题。

如果您没有得到PDF文件,您得到了什么?有错误吗?服务器的响应是什么?将显示下载窗口,但下载的文件不是我想要的文件。下载的文件是.php扩展名。我已经删除了“header('Content-Disposition:attachment;header(“Content-Transfer-Encoding:binary\n”)”),但我仍然没有得到pdf文件。确切地说,当你说“得到php页面”时,我得到了php页面(text.php)你的确切意思是什么?你得到了一个名为
text.php
的PDF文件吗?你得到了php代码可见的实际php文件吗?text.php不包含显示我以前尝试下载PDF的页面的代码。如果你在客户端上看到了实际的php代码,那么问题与代码本身无关。你的php服务器没有进程使用PHP代码。这是一个服务器配置问题。你不应该在客户端看到PHP代码。我如何设置服务器配置?
header("Content-Type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . OCIResult($stid,'PDFFILE') . '"');    
header("Content-Length: " . filesize(OCIResult($stid,'PDFFILE')->load()));
header('Content-Disposition: attachment; header("Content-Transfer-Encoding: binary\n");