I want to get file path in php file using simple javascript, but there is an error given as follows. All code was working fine but when i add $sourcePath = $_FILES['userImage']['tmp_name']; to line no. 16 the error displayed.
Error:
Undefined index: userImage in ...\actionpdf.php on line 16
FPDF error: Some data has already been output, can't send PDF file
Javascript Code:
document.getElementById('idForm').action = 'actionpdf.php';
document.getElementById('idForm').submit();
PHP Code:
<?php
require('WriteHTML.php');
$pdf=new PDF_HTML();
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak(true, 15);
$pdf->AddPage();
$pdf->Image('logo.png',18,13,33);
$pdf->SetFont('Arial','B',14);
$pdf->WriteHTML('<para><h1>Techzax Programming Blog, Tutorials, jQuery, Ajax, PHP, MySQL and Demos</h1><br>
Website: <u>www.techzax.com</u></para><br><br>How to Convert HTML to PDF with fpdf example');
$pdf->SetFont('Arial','B',7);
$sourcePath = $_FILES['userImage']['tmp_name'];
//echo $sourcePath;
$htmlTable='<TABLE style"border:none">
<TR>
<TD>Name:</TD>
<TD style="border:2px;">'.$sourcePath.'</TD>
</TR>
<TR>
<TD>Email:</TD>
<TD>'.$_POST['block-name'].'</TD>
</TR>
<TR>
<TD>URl:</TD>
<TD>'.$_POST['block-name'].'</TD>
</TR>
<TR>
<TD>Comment:</TD>
<TD>'.$_POST['block-name'].'
</TD>
</TR>
</TABLE><input type="checkbox" name="letter" value="letter" id="letter" checked="checked">';
$pdf->WriteHTML2("<br><br><br>$htmlTable");
$pdf->SetFont('Arial','B',6);
$pdf->Output();
?>