tags:

views:

66

answers:

3
A: 

Set the content type header at the beginning of your php file, so that the browser understands that an image is to be displayed. (Use image/png for png files).

header('Content-type: image/jpeg');
styts
it does not work
rajanikant
A: 

I can't find any HTTPResponse header being manipulated. You will need to set the header content-type to the corresponding image before flushing out the image binary.

E.g.

header('Content-Type: image/jpeg');

Read this related post and reference.

PS: You need to make sure nothing no other HTML is sent before and after the image.

o.k.w
but it also not work
rajanikant
it gives src as my file name
rajanikant
@rajanikant, please refer to Álvaro's answer. I think he is spot on about your problem.
o.k.w
+1  A: 

Your code suggests you're trying to inject an image inside your HTML. While it can actually be done (and some browsers actually support it), the syntax is different and I'm sure anyway that it's not what you're trying to accomplish. You have two options:

  1. Save the image into disc (you already have a save method in your class) and load from an <img> tag
  2. Generate a Content-Type header, output the binary stream and stop the script execution.
Álvaro G. Vicario