I would like to display some images which their URL is saved in DB, but the images are not diplayed and when I right click on the image and select "view image" I see this message:
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
This is my code:
<?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>
Also, I see this warning in php error log:
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
while imdbImage.php is:
<?php
header("Content-type: image/jpeg");
//URL for IMDb Image.
$url = rawurldecode($_REQUEST['url']);
echo file_get_contents($url); //THIS IS LINE 6 //
?>
When I try with the following code, it only shows the images locally.
<td><img class='imdbImage' id="image" src=<?php echo $row['posterLink']; ?>' alt="" /></td>
Could someone kindly let me know what is the problem with my code and why the images are not shown?
Thanks