0
    function load_image() {
       header('ETag: 8ba645e803f8dc1020b1a74b5ec03fba');
       header('Last-Modified: Tue, 21 Jul 2015 10:36:31 GMT');
       header('Content-Type: image/jpeg');
       header('Content-Length: 41374' );
       echo readfile("images/France/paris.jpg");
       exit;
    }

I have this codeigniter function which should read image and load it in browser but I have the error

 /France/paris.jpg” cannot be displayed because it contains errors.
Karim Samir
  • 1,470
  • 17
  • 17

2 Answers2

2

You must not output anything before header(). Just start your document with <?php followed by the code for displaying the image. Skip the html tags. Do not even write a single blank-line before header().

ob_clean — Clean (erase) the output buffer and helpful in manipulating the images and PHP Should I use ob_clean after ob_start

Community
  • 1
  • 1
Linus
  • 899
  • 3
  • 19
  • 33
0

I have checked whether the image path is correctly set or if it passes only null value.

If image not found then it gives this error in Firefox. In IE, it shows sample square box. No error message is shown in Chrome.

So, Check if the image passes correctly or pass null value.

In my code I have checked like this

if(!empty("Passing image here path")) 
{
compress image here
}
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Yogesh
  • 1