MySQL Forums
Forum List  »  PHP

Re: image display problem from mysql database
Posted by: Rick James
Date: March 14, 2009 02:08PM

Call header() with the right 'mime' type to announce that it is an image -- and you need to specify jpg/gif/...

Also get rid of the <BR>. The body should have nothing but the image.

And this cannot be a part of a page. It needs to be a separate call. That is, the html page will include something like
<img src=http://.../myimg.php?id=123 height=234 width=345>
Your "myimg.php" program does basically: header(), SELECT the img, echo the image.

The height= and width= are a kindness to the user -- it helps the browser be less jumpy. And if the values exactly match the image, then there is less work for the browser.

header('Content-type: image/jpeg');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . strlen($jpg));
echo $jpg;

And... If you have a closing "?>" (not really necessary), be sure not to have a blank line after it.

Options: ReplyQuote


Subject
Written By
Posted
Re: image display problem from mysql database
March 14, 2009 02:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.