Code that calls showpdf.php:
<form name="Proof1" method="post" action="showpdf.php">
<input type="hidden" value="1000d/60026_sample.pdf" name="pdfname">
<a href="javascript:void(0)" target="new" onClick="document.forms['Proof1'].submit(); return false;">View PDF Proof</a>
</form>
showpdf.php code:
session_start();
require('global.php');
if ($_POST['pdfname'] == "") { exit; }
$split_pdf_path = split("/", $_POST['pdfname']);
load_pdf($PROOF_PDF_PATH . $splitpdfpath[0] . "/", $splitpdfpath[1]);
load_pdf function in global.php:
function load_pdf($path, $filename) {
if (file_exists($path . $filename) == false) {
print "Sorry! Unable to find the requested PDF. Please contact " . $_SERVER['SERVER_ADMIN'] . " immediately!";
print "<br><br>[" . $path . $filename . "]";
exit;
}
$pdfhandle = fopen($path . $filename, "r");
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=" . $filename);
fpassthru($pdfhandle);
fclose($pdfhandle);
}