我正在使用此代码在php中查看PDF文件,而不是仅在浏览器中打开它。
if(isset($_SESSION['access_token']))
{
require_once('includes/db_connect.php');
$id = mysqli_real_escape_string($mysqli, $_GET['id']);
$attest = mysqli_real_escape_string($mysqli, $_GET['attest']);
$heat = mysqli_real_escape_string($mysqli, $_GET['heat']);
$mat = mysqli_real_escape_string($mysqli, $_GET['mat']);
$dikte = mysqli_real_escape_string($mysqli, $_GET['dikte']);
$file = '../thure/uploads/attesten/'.$id.'.pdf';
$filename = 'Certificaat plaat '.$id.' met '.$attest.' heat '.$heat.' '.$mat.' '.$dikte.'mm.pdf';
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file));
header('Accept-Ranges: bytes');
@readfile($file);
}
在Explorer,Chrome等中显示的页面标题是php文件的名称。如何在此处设置自定义名称(与PDF相同)?
当我使用下面的代码时,pdf显示为纯文本。
<!DOCTYPE html>
<head>
<title>Torza</title>
</head>