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条回答

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器