我有用於將數據保存爲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