[英]Does app engine remove html headers from php pages?
I'm using a PHP page that shows a PDF in the browser. 我正在使用一个PHP页面,该页面在浏览器中显示PDF。 The content of the PDF is in a session variable. PDF的内容在会话变量中。
When I use this page on my server, it works perfectly and I can see the PDF as it has to be seen. 当我在服务器上使用此页面时,它可以正常运行,并且可以看到PDF,因为它必须被看到。
When I use this same page on App engine I get "%PDF-1.7 %..." 当我在App引擎上使用同一页面时,我得到“%PDF-1.7%...”
What am I doing wrong ? 我究竟做错了什么 ?
Here is the code of the page I use 这是我使用的页面的代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
// Inserción de parametros y de funciones
require_once("RKR_P_Parametros.php");
require_once("tUnua_Funciones.php");
session_start();
$ArchivoPDF = LeerVariableSesion("ArchivoPDF");
$NombreArchivoPDF = LeerVariableSesion("NombreArchivoPDF");
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$NombreArchivoPDF.'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
echo $ArchivoPDF;
?>
</body>
Thank you for your help. 谢谢您的帮助。
Jean-Daniel Mâlet. 让·丹尼尔·马莱特(Jean-DanielMâlet)。
-- -
I'v been investigating around output buffering and I've found a solution which could not be the best... 我一直在研究输出缓冲,但发现了一个解决方案可能不是最好的...
I first add a php.ini file to my App Engine project : 我首先将php.ini文件添加到我的App Engine项目中:
output_buffering = 12288
I then modified my php code this way : 然后,我以这种方式修改了我的php代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
// Inserción de parametros y de funciones
require_once("RKR_P_Parametros.php");
require_once("tUnua_Funciones.php");
session_start();
$NombreArchivoPDF = LeerVariableSesion("NombreArchivoPDF");
function RKR_VPDF_Callback($Buffer)
{
$ArchivoPDF = LeerVariableSesion("ArchivoPDF");
$Buffer .= $ArchivoPDF;
return $Buffer;
}
ob_start(RKR_VPDF_Callback);
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$NombreArchivoPDF.'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ob_flush();
?>
</body>
And it worked. 而且有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.