Goodafternoon,我做了這個腳本,但我不能得到我錯的地方,它沒有保存PDF,因爲我試圖編程。 謝謝,如果有任何建議。 我知道問題出在邏輯裏面:函數file_newname但我不知道在哪裏。 預先感謝您。FPDF沒有保存PDF在服務器
<?php
require('fpdf.php');
class PDF extends FPDF{
function Header(){
$this->Image('img/oet.png',10,6,30);
$this->SetFont('Helvetica','B',25);
$this->Cell(55);
$this->Cell(100,10,"TITLE",0,0,'C');
$this->SetFont('Helvetica','B',18);
$this->Ln(10);
$this->Cell(55);
$this->Cell(100,10,"SUBTITLE",0,0,'C');
$this->Ln(20);
}
function Footer(){
$this->SetY(-15);
$this->SetFont('Times','I',8);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function file_newname($filename){
if($pos = strrpos($filename, '.')) {
$name = substr($filename, 0, $pos);
$ext = substr($filename, $pos);
}else{
$name = $filename;
}
$newpath = 'docs/'.$filename;
$counter = 0;
while (file_exists("docs/")) {
$filename = $name .'_'. $counter . $ext;
$newpath = "docs/".$filename;
$counter++;
}
$this->Output("docs/".$filename);
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<=10;$i++){
$pdf->Cell(0,10,'Printing line number '.$i,0,1);
}
$pdf->Output();
$pdf->file_newname(date("Ymd").".pdf");
?>
'$這 - >輸出(「文檔/".$ NEWNAME);''..目錄docs'有?? –
是的,「docs /」是正確的 –