我想將PDF文件保存到用戶指定的目錄中。我正在使用FPDF。並且代碼如下:使用FPDF將文件保存到預先指定的目錄中
<?php
//echo "<meta http-equiv=\"refresh\" content=\"0;url=http://www.train2invest.net/useradmin/atest_Khan.php\">";
require('fpdf.php');
//create a FPDF object
$pdf=new FPDF();
//set font for the entire document
$pdf->SetFont('times','',12);
$pdf->SetTextColor(50,60,100);
//set up a page
$pdf->AddPage('P');
$pdf->SetDisplayMode(real,'default');
//Set x and y position for the main text, reduce font size and write content
$pdf->SetXY (10,60);
$pdf->SetFontSize(12);
$pdf->Write(5,'Dear Ms.XYX');
$filename="test.pdf";
//Output the document
$dir = "/G:/PDF/test.pdf/"; // full path like C:/xampp/htdocs/file/file/
$pdf->Output($dir.$filename,'F');
?>
現在,即使我把"G:\PDF\"
的文件名不保存它!我試過以下內容:
$filename="G:\PDF\test.pdf";
$pdf->Output($filename.'.pdf','F');
$filename="G:\\PDF\\test.pdf";
$pdf->Output($filename.'.pdf','F');
$filename="G:/PDF/test.pdf";
$pdf->Output($filename.'.pdf','F');
$filename="/G:/PDF/test.pdf/";
$pdf->Output($filename.'.pdf','F');
我檢查了我想寫的目錄有寫入/讀取權限,它在那裏。它仍然行不通!
請幫助別人......
使用格式化`代碼塊`它很難讀取你的問題和`php`標籤以獲得正確的人的注意力 – Ish 2010-12-02 21:02:39
你有沒有嘗試過將它輸出到瀏覽器以查看`Output()`例程是否工作所有?將'F'切換到'D'來嘗試。 – Orbling 2010-12-02 21:40:21