脚本完成后,PHP文件将关闭浏览器。需要它显示“下载完成”消息

时间:2015-03-04 13:01:27

标签: php browser

我有一个PHP脚本,它引用了另外两个PHP脚本。这三个脚本如下:

母版页:

    <?php
    header("Content-disposition: attachment;
    filename=huge_document."
    header("Content-type: application/pdf");
    $FullName = $_GET["FullName"];
    global $FullName;
    Include("Code.php");
    Include ("GetPDFfromServer.php");
    echo ("Download Complete");
    ?>

Code.php:

<?php
require_once ("fpdf17/fpdf.php");
require_once ('FPDI-1.5.2/fpdi.php');
$pdf =& new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("Secret.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
//use the imported page and place it at point 0,0; calculate width and height
//automatically and adjust the page size to the size of the imported page
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
// now write some text above the imported page
$pdf->SetFont('Arial', '', '36');
$pdf->SetTextColor(0,0,0);
//set position in pdf document
$pdf->SetXY(195, 240);
//$pdf->Write(0, '|');
$pdf->SetXY(0,240);
$pdf->SetMargins(0,"",0);
//force the browser to download the output
$pdf->Cell(0,0,$FullName,0,0,"C",false,"");
//first parameter defines the line height

$pdf->Output('temp/Secret.pdf', "F");
//return;
?>

GetPDFfromServer.php:

<?php

//header("Content-disposition: attachment; filename=huge_document.pdf");
//header("Content-type: application/pdf");
readfile("temp/NIA_SM_Policy_Digital-CertificateNEW.pdf");
Echo("Download Complete");
//return;
?>

当我加载母版页(例如:www.example / MasterPage.php?FullName = Mark%20Francis)时,它成功完成所有功能(创建个性化.pdf,将其下载到服务器,然后将其下载到服务器浏览器)。但我想显示一条消息,说明&#34;下载完成&#34;或者沿着那些方向的东西,但浏览器标签立即关闭。

非常感谢任何帮助。

谢谢!

1 个答案:

答案 0 :(得分:0)

我更新的重定向代码:

<!DOCTYPE html>
<html>
<body>

<?php
readfile("temp/Secret.pdf");
?>

<script type="text/javascript">
window.location = "http://www.google.com/"
</script>


</body>
</html>