[英]How to download PDF file from blob oracle using PHP?
I want to download blob file from oracle, that is PDF file, this is my code to get and download file:我想从 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");
}
?>
but when i run this code,i not get pdf file.. something wrong with my code??但是当我运行这段代码时,我没有得到 pdf 文件。我的代码有问题吗??
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");
You're sending the Content-Disposition
header twice.您发送了两次Content-Disposition
标头。 You probably don't even need the second one, the client should know all it needs to know about the stream from the Content-Type
header.您可能甚至不需要第二个,客户端应该从Content-Type
标头中知道它需要知道的关于流的所有信息。 Omit the second Content-Disposition
so you're not over-writing the header that has the filename.省略第二个Content-Disposition
,这样您就不会覆盖具有文件名的标头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.