我正在研究PHP。我需要将值传递给图像PHP页面,并创建一个图像,但它不起作用。
这个文件是生成php:
if ( $submit == "View Report" )
{
header("Content-Type: application/pdf");
flush();
// Run HTMLDOC to provide the PDF file to the user...
// Use the --no-localfiles option for enhanced security!
passthru("htmldoc --no-localfiles --no-compression -t pdf14 --quiet --jpeg --browserwidth 1100 --webpage ".
"--color --linkcolor 000099 --bodyfont Sans-Serif --fontsize 8 ".
" --landscape --header ctl --footer ..: --headfootfont Sans-Serif --headfootsize 8 --size Letter ".
" --logoimage https://".$urlbase."ewaclogo.jpg ".
" https://".$urlbase."ewac_cancertreport.php?dates=".$dataendyear.":".
"01:01:".$dataendyear.":12:31:".$dataendyear.":".$dataendmonth.":".$dataendday);
------------------------------------------------------------------------
other PHP files:
echo '<BR>'."\n".
'<TABLE WIDTH=50% CELLSPACING=0 CELLPADDING=2 BORDER=0>'."\n".
' <TR BGCOLOR="#FFFFFF"><TD ALIGN=CENTER>'."\n";
echo " <IMG SRC=\"ewac_cancertsummarygraph.php?startdate=".$startdate."&enddate=".$enddate.
"&dataenddate=".$dataenddate."&size=1000\">".
"</TD></TR></TABLE>"."\n";
echo "<TABLE WIDTH=1000 CELLSPACING=0 CELLPADDING=2 BORDER=0><TR><TD ALIGN=CENTER>
Figure 1 - ".$startyear." CanCERT Incident Summary</TD>"."\n".
"</TABLE>"."\n";
echo "<!-- PAGE BREAK -->";
echo '<BR>'."\n".
'<TABLE WIDTH=50% CELLSPACING=0 CELLPADDING=2 BORDER=0>'."\n".
' <TR BGCOLOR="#FFFFFF"><TD ALIGN=CENTER>'."\n";
echo " <IMG SRC=\"ewac_cancertcomparisongraph.php?startdate=".$startdate."&enddate=".
$enddate."&dataenddate=".$dataenddate."&size=1000\">".
"</TD></TR></TABLE>"."\n";
echo '<TABLE WIDTH=1000 CELLSPACING=0 CELLPADDING=2 BORDER=0><TR><TD ALIGN=CENTER>
Figure 2 - CanCERT Incident Summary '.($dataendyear-1).'/'.$dataendyear.' Comparison</TD>'."\n".
'</TABLE>'."\n";
echo "<!-- PAGE BREAK -->";
当我检查&#34;查看源&#34;时,它显示如下,看起来没问题。我不知道问题出在哪里,但图像没有显示出来。
<TABLE WIDTH=50% CELLSPACING=0 CELLPADDING=2 BORDER=0>
<TR BGCOLOR="#FFFFFF"><TD ALIGN=CENTER>
<IMG SRC="ewac_cancertsummarygraph.php?startdate=2016-1-1&enddate=2016-12-31&dataenddate=2016-4-11&size=1000"></TD></TR></TABLE>
<TABLE WIDTH=1000 CELLSPACING=0 CELLPADDING=2 BORDER=0><TR><TD ALIGN=CENTER>
Figure 1 - 2016 CanCERT Incident Summary</TD>
</TABLE>
<!-- PAGE BREAK --><BR>
<TABLE WIDTH=50% CELLSPACING=0 CELLPADDING=2 BORDER=0>
<TR BGCOLOR="#FFFFFF"><TD ALIGN=CENTER>
<IMG SRC="ewac_cancertcomparisongraph.php?startdate=2016-1-1&enddate=2016-12-31&dataenddate=2016-4-11&size=1000"></TD></TR></TABLE>
<TABLE WIDTH=1000 CELLSPACING=0 CELLPADDING=2 BORDER=0><TR><TD ALIGN=CENTER>
Figure 2 - CanCERT Incident Summary 2015/2016 Comparison</TD>
当我只检查图像时,显示:
ÿØÿà�JFIF��`�`��ÿþ�>CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality
ÿÛ�C�
$.' ",#(7),01444'9=82<.342ÿÛ�C
2!!22222222222222222222222222222222222222222222222222ÿÀ� ["�ÿÄ�����������
ÿÄ�µ���}�!1AQa"q2‘¡#B±ÁRÑð$3br‚
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢ £¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ��������
ÿÄ�µ��w�!1AQaq"2B‘¡±Á #3RðbrÑ
$4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢ £¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ���?�÷ú(¢€9¿ø –môý+L·Žë^Õâ°†bV!±w<’7dE9 |ÍÀ¸<)âYµ‡Ô4NÞ;]{ItŠþIhŽõÜ’FÝÑÔdó/ Žäñ_†¦ÖOÕtˈíuí%Þ[ ¦¢;×kÇ"÷GQ‚G̼{ž›G}CUÔî#º×µgIo愈l]©kÙN?3rIì�:#fA!E.c‘øÒy1y¾o–žg÷öŒþtú (žL^o›å§™ýý£? Ay_f¸—ËO3ËoŸhÏOZµPÞÇ•Çýsoå@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó? ¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó? ¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:<˜¼ß7ËO3ûûF:}�Ï&/7ÍòÓÌþþÑŸÎ&/7ÍòÓÌþþџΟE�3É‹Íó|´ó?¿´gó£É‹Íó|´ó?¿´gó§Ñ@òbó|ß-<Ïïíüèòbó|ß-<ÏïíüéôP<˜¼ß7ËO3ûûF:} PEPEPEPPÞÇ•ÇýsoåST7Ÿñåqÿ�\ÛùPÔQE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�QE�
çüy\×6þU5Cyÿ�WõÍ¿•�MEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEPE
答案 0 :(得分:1)
您向我们展示了生成HTML的PHP,而不是生成图像的PHP。这就是问题所在。
您引用的内容在呈现为文本(或HTML)时看起来像是图像文件的开头。
默认情况下,PHP输出Content-Type: text/html
标题(告诉浏览器它是HTML)。您需要覆盖它(使用header()
方法)为您正在使用的图像格式指定正确的内容类型(例如image/jpeg
)。
答案 1 :(得分:-1)
这样更清洁。
<TABLE WIDTH=50% CELLSPACING=0 CELLPADDING=2 BORDER=0>
<TR BGCOLOR="#FFFFFF"><TD ALIGN=CENTER>
<IMG SRC="ewac_cancertcomparisongraph.php?startdate=<?php echo $startdate."&enddate=".$enddate."&dataenddate=".$dataenddate."&size=".$size;?>"></TD></TR></TABLE>
<TABLE WIDTH=1000 CELLSPACING=0 CELLPADDING=2 BORDER=0><TR><TD ALIGN=CENTER>
Figure 1 - 2016 CanCERT Incident Summary</TD>
</TABLE>
<!-- PAGE BREAK --><BR>
<TABLE WIDTH=50% CELLSPACING=0 CELLPADDING=2 BORDER=0>
<TR BGCOLOR="#FFFFFF"><TD ALIGN=CENTER>
<IMG SRC="ewac_cancertcomparisongraph.php?startdate=<?php echo $startdate."&enddate=".$enddate."&dataenddate=".$dataenddate."&size=".$size;?>"></TD></TR></TABLE>
<TABLE WIDTH=1000 CELLSPACING=0 CELLPADDING=2 BORDER=0><TR><TD ALIGN=CENTER>
Figure 2 - CanCERT Incident Summary 2015/2016 Comparison</TD>