【发布时间】:2014-12-22 11:09:42
【问题描述】:
我想显示一些图像,它们的 URL 保存在数据库中,但图像没有显示,当我右键单击图像并选择“查看图像”时,我看到了以下消息:
http://localhost/imdbImage.php?url=http://ia.media-imdb.com/images/M/MV5BMjExNzM0NDM0N15BMl5BanBnXkFtZTcwMzkxOTUwNw@@._V1_SY317_CR0,0,214,317_AL_.jpg cannot be diplayed because it contains errors
这是我的代码:
<?php
while ($row = $query->fetch(PDO::FETCH_ASSOC)):
?>
<tr>
<td><img class='imdbImage' id="image" src='imdbImage.php?url=<?php echo $row['posterLink']; ?>' alt="" /></td>
<td> ....
...
</tr>
另外,我在 php 错误日志中看到了这个警告:
PHP Warning: file_get_contents(Null): failed to open stream: No such file or directory in /var/www/imdbImage.php on line 6, referer: http://localhost/movielist.php
而 imdbImage.php 是:
<?php
header("Content-type: image/jpeg");
//URL for IMDb Image.
$url = rawurldecode($_REQUEST['url']);
echo file_get_contents($url); //THIS IS LINE 6 //
?>
当我尝试使用以下代码时,它仅在本地显示图像。
<td><img class='imdbImage' id="image" src=<?php echo $row['posterLink']; ?>' alt="" /></td>
谁能告诉我我的代码有什么问题以及为什么没有显示图像?
谢谢
【问题讨论】: