我有用于将数据保存为pdf格式的php代码。但是现在,它只是简单地以pdf格式打开数据,而不是提示我将其保存为pdf。我怎样才能做到这一点? 我的代码如下:如何提示保存pdf而不是用fpdf打开它
<?php
if(!empty($_POST['submit']))
{
$f_name=$_POST['first_name'];
$l_name=$_POST['last_name'];
$gender=$_POST['gender'];
$dob=$_POST['dob'];
$mobile=$_POST['mobile'];
$email=$_POST['email'];
require("fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont("Arial","B",16);
$pdf->Cell(10,10,"welcome {$f_name}",1,0);
$pdf->Cell(50,10,"Name :",1,0);
$pdf->Cell(50,10,"$l_name",1,0);
$pdf->Cell(50,10,"gender :",1,0);
$pdf->Cell(50,10,"$gender",1,1);
$pdf->Cell(50,10,"Mobile :",1,0);
$pdf->Cell(50,10,"$mobile",1,1);
$pdf->Cell(50,10,"Email :",1,0);
$pdf->Cell(50,10,"$email",1,1);
$pdf->Output("D", "filename.pdf");
}
?>
浏览器是否提示保存或打开文件取决于浏览器配置。这取决于每个用户,并且您无法从服务器端控制它。 –
你用这个来保存PDF $ filename =“path/example.pdf”; $ pdf->输出($ filename,'F'); – Gopalakrishnan
不,我没有,我应该如何编辑我的代码来做到这一点? – compcrk