I am using the FPDF library for generating PDF files by PHP. This library is working fine with plain text(i.e PDF files are generating for any text), but this is giving me an error of FPDF error: Missing or incorrect image file:{MY_FILE_PATH}
while trying to add an image to my PDF page. Accessed that file path through the browser, then the corresponding image is appearing fine.
My code is:
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Write(10, 'Example image');
$image_path = MY_FILE_PATH; // This variable contains my actual file path
$pdf->Image($image_path, 10, 10, 350, 450);
$pdf->Output();
This code is working perfectly in my localhost and generating the corresponding PDF files even with the images also, but this is not working after moving to the server.
I have tried with these possibilities like:
With absolute and relative paths for the image.
Tried with a local image placed in the same folder.
All image formats like jpg, png and gif also.
Checked the permissions for the image and corresponding folders also.
None of these cases are working for me, stuck with this problem, can anyone help me to slove this issue.
Thanks!
Siva ...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…