I am trying to show an image in a popup window using file_get_contents function and an echo statement.
Here is the code I have in the first view
<a href='javascript:window.open("index.php?option=com_jsmdownload&view=request&tmpl=component&layout=showimage&img=icon-36-ldpi.png", "Image View", "toolbar=no, location=no, width=400, height=400")'>Click</a>
Below is the code in my second layout inside the same view
$image = JURI::base().DS.'files'.DS.'images'.DS.'icon.png';
//echo $image;
$content = file_get_contents($image);
header('Content-Type: image/png');
echo $content; exit();
When I click the 'Click' anchor in the first view it opens the popup window and it shows garbage inside.
The image path is correct and if I brows the image path in an another browser URL it shows the image.
Not sure what I am missing. Can someone please help on this?