【问题标题】:Unable to get the size of the image ( codeigniter , tcpdf , php )无法获取图像的大小(codeigniter、tcpdf、php)
【发布时间】:2017-04-10 06:16:21
【问题描述】:

我在尝试使用 codeigniter 在 tcpdf 中显示图片时遇到问题,

这是我的 pdf 视图:

$base_url=base_url();

// NON-BREAKING ROWS (nobr="true")

$tbleauproduct = <<<EOD
<br /><br /><br />
<table border="1" align="center">
    <tr>
        <th>picture</th>
        <th>Product name</th>
        <th>Price</th>
        <th>Quantity</th>
    </tr>
    <tr>
        <td><img src="$base_url/assets/$picture" /></td>
        <td>$name</td>
        <td>$price</td>
        <td>$qty</td>
    </tr>
</table>
EOD;

$pdf->writeHTML($tbleauproduct, true, false, true, false, '');

结果如下:

TCPDF ERROR: [Image] Unable to get the size of the image: http://localhost:8888/open_bay//assets/130501153059-htc-one-1024x576.jpeg

【问题讨论】:

标签: php codeigniter codeigniter-2 codeigniter-3 tcpdf


【解决方案1】:
$file_path = base_url().'assets/130501153059-htc-one-1024x576.jpeg';
$size = filesize($file_path);

【讨论】:

  • 我使用这种方法,但我发现了这个问题:消息:filesize(): stat failed for localhost:8888/open_bay/assets/…
  • 可以通过提供解释或官方文档链接来改进纯代码答案。答案不仅可以帮助 OP 解决问题,还可以帮助未来的 SO 研究人员快速解决他们的问题。尽可能使每篇帖子都达到最高质量,这样您就可以从点赞中获得更多的代表点数。
猜你喜欢
  • 1970-01-01
  • 2015-01-19
  • 2011-12-01
  • 1970-01-01
  • 2012-04-15
  • 1970-01-01
  • 1970-01-01
  • 2018-06-17
  • 2011-06-28
相关资源
最近更新 更多