douzhuo3233 2015-10-24 16:56
浏览 76

文件上传图片我在PHP中使用javascript提交未定义

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(); 

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥188 寻找能做王者评分提取的
    • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
    • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
    • ¥15 写论文,需要数据支撑
    • ¥15 identifier of an instance of 类 was altered from xx to xx错误
    • ¥100 反编译微信小游戏求指导
    • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
    • ¥15 学不会递归,理解不了汉诺塔参数变化
    • ¥15 基于图神经网络的COVID-19药物筛选研究
    • ¥30 软件自定义无线电该怎样使用