我做了一个小表格,我想要它保存为PDF格式。我成功地使用FPDP设置了所有内容,但我想在单击“保存”按钮后立即下载特定目录(例如文件夹)上的文件。
这是我的FPDF代码
<?php
session_start();
$user = $_SESSION['username'];
$sicep = $_SESSION['sicep'];
$notesicep = $_SESSION['notesicep'];
require ('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',11);
$pdf->Cell(100, 8, 'Operatore Centrale Operativa: '.$user, 1 ,1);
$pdf->Cell(100, 8, 'Effettuato in data: ' .date("d/m/Y"). ' In ora: '.date("h:ia") , 1 ,1);
$pdf->Cell(180, 10, 'Verifica funzionale sistema SICEP MVS NET:',1,1);
$pdf->Cell(180, 10, $sicep,1,1);
$pdf->Cell(180, 10, 'Note: '.$notesicep,1,1);
$pdf->Output("D", date("d/m/Y")."-".date("h:ia").".pdf");
?>
我设法用当前的日期和时间保存了文件名,但我也想在一个认证目录中自动下载该文件,比方说在桌面上:
C:\user\user\Desktop
但我想不出办法。有什么帮助吗?
发布于 2018-10-16 13:35:11
不可能在php级别上决定将文件存储在用户机器上的位置(当您单击“下载”按钮时,您将获得选择位置的对话框窗口,或者它将使用默认浏览器设置)。
如果希望将其存储在特定目录(服务器上)中,可以向output()
方法添加路径,例如:
$pdf->Output("D", '/some/path/' . date("d/m/Y")."-".date("h:ia").".pdf");
https://stackoverflow.com/questions/52836619
复制相似问题