Hello, i have a problem with displaying .jpg images in pdf, when using php & FPDF.
If I write path to image in '2php.php' manually, it's working properly (image is displayed in created doc.pdf file) but when I try to use it with variables received from 'main.php' an error occures. Error: FPDF error: Unsupported image type: jpg
Is there some solution to this? tnx
MAIN.PHP:
<html>
<body>
<?php
$PATH = "path to image dir..";
$file = "pic.txt";
$lines = count(file($file));
$handle = @fopen($file, "r");
if ($handle) {
while (!feof($handle)) {
$pic_array[] = fgets($handle, 4096);
}
fclose($handle);
}
?>
<table BORDER="1">
<?php for($counter = 0;$counter<=$lines; $counter++){ ?>
<tr>
<td><?php echo $pic_array[$counter];?></td>
<td> <form method="POST" action="2php.php" name="form" id="form">
<input type="hidden" name="path" value="<?php echo $PATH; ?>">
<input type="hidden" name="pic" value="<?php echo $pic_array[$counter]; ?>">
<input type="submit" value="<?php echo $pic_array[$counter];?>" name="PDF"></td></tr>
<?php }?>
</form>
</td></table>
</body>
</html>
2php.php
<?php
require('fpdf.php');
$pic = $_POST["PDF"];
$path=$_POST['path'];
$path1 ="".$path."".$pic."";
//$pic1 = 'pic1.jpg';
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Image($path1, 1, 10, 250, 250);
//$pdf->Image($pic, 1, 10, 250, 250);
//$pdf->Image($pic1, 1, 10, 250, 250);
$pdf->Cell(40,10,$path1);
//$pdf->Cell(40,10,$pic1);
$pdf->Output();
?>
example of pic.txt:
pic1.jpg
pic2.jpg
picure3.jpg
image.jpg