I want to save the PDF file into a user specified directory. I am using FPDF. And the code is as below:
<?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');
?>
Now even if I put "G:\PDF\"
in the filename it doesn't save it!! I have tried the following:
$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');
I have checked that the directory i am trying to write has write/read permission and it's there. IT STILL DOESN'T WORK!
PLEASE help somebody...
Having struggled with this myself, there are three things one has to ensure, two of which are mentioned in other posts on this topic:
Have you tried file upload? I think you and I might be trying to do the same thing and this seems to work. I am working on a shared drive as well.
http://php.net/manual/en/features.file-upload.post-method.php