How do I set a header() and echo an image using CodeIgniter? How do I set a header() and echo an image using CodeIgniter? codeigniter codeigniter

How do I set a header() and echo an image using CodeIgniter?


It turns out that the image in the database was corrupt, and hence not displaying, because I had added addslashes() to the file contents (not really sure why, seem to remember reading it was useful in combating XSS vulnerabilities).

Removing that meant I had non-corrupt images stored and then they displayed okay.


First You need to start ob_start() just before on_clean() then you need to write like header().Here is the follow.

ob_start();ob_clean();header ("Content-type: image/png");

?>Try this let me know is this working or not hopefully it will help you.