I am trying to display an image file in <img>
tag using PHP file handling functions but I'm getting following error instead of an actual image:
image cannot be displayed because it contains errors
Here's my code to read and display the image file:
<?php
header("content-type: image/jpeg");
$filename = "images/sunset.jpg";
$handle = fopen($filename, "rb");
$img= fread($handle, filesize($filename));
fclose($handle);
?>
<img src="<?php echo $img; ?>" alt="image" />
Where I am doing wrong?