By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

how to display the data of an image file

P: n/a
Hi all,

Assuming I have stored the binary data of an image file in a blob field
of a table, how can I display it as an image in a web page? I found some
instructions on the web, such as

header('application/octet-stream');
echo $imgdata;

I don't know why I always get this warning.

----------------
Warning: Cannot modify header information
-------------

How can I get rid of it and show the image as an element of the current web
page?

Thanks, kevin

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
Hi all,

Assuming I have stored the binary data of an image file in a blob field of
a table, how can I display it as an image in a web page? I found some
instructions on the web, such as

header('application/octet-stream');
echo $imgdata;
First mistake - send the proper Content-type header! If it's a JPEG, tell
the browser it's a JPEG.

I don't know why I always get this warning.

----------------
Warning: Cannot modify header information -------------

How can I get rid of it and show the image as an element of the current
web page?


That means some content was already sent. Check for any whitespace before
your PHP code.

HTH,
La'ie Techie

Jul 17 '05 #2

P: n/a
You can't have any html output before you issue the header command -
even blank lines in any html blocks of code that might be on your page
would be enough to give you that error. (I got this error alot when
first learning php)

I haven't worked with image binary data stored in a blob field, I've
only used gd command libraries to create inline images. Maybe someone
else can address that part of your question.

Monte

Kevin wrote:
Hi all,

Assuming I have stored the binary data of an image file in a blob field
of a table, how can I display it as an image in a web page? I found some
instructions on the web, such as

header('application/octet-stream');
echo $imgdata;

I don't know why I always get this warning.

----------------
Warning: Cannot modify header information
-------------

How can I get rid of it and show the image as an element of the current web
page?

Thanks, kevin


Jul 17 '05 #3

P: n/a
never mind, I have gotten the answer. thank you all.

"L?ie Techie" <laie@win_remove_get_nospam_solutions.com> дʼ
news:1111732373.9ebc38615521a8cd8e0f9fb66ebdd2a6@t eranews...
On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
Hi all,

Assuming I have stored the binary data of an image file in a blob field of a table, how can I display it as an image in a web page? I found some
instructions on the web, such as

header('application/octet-stream');
echo $imgdata;


First mistake - send the proper Content-type header! If it's a JPEG, tell
the browser it's a JPEG.

I don't know why I always get this warning.

----------------
Warning: Cannot modify header information -------------

How can I get rid of it and show the image as an element of the current
web page?


That means some content was already sent. Check for any whitespace before
your PHP code.

HTH,
La'ie Techie

Jul 17 '05 #4

P: n/a

"La?ie Techie" <laie@win_remove_get_nospam_solutions.com> wrote in message
news:1111732373.9ebc38615521a8cd8e0f9fb66ebdd2a6@t eranews...
On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
Hi all,

Assuming I have stored the binary data of an image file in a blob field of a table, how can I display it as an image in a web page? I found some
instructions on the web, such as

header('application/octet-stream');
echo $imgdata;


First mistake - send the proper Content-type header! If it's a JPEG, tell
the browser it's a JPEG.


Not much of a mistake, really, since modern browsers determine the image
type from the data stream--not the mime header. Otherwise they wouldn't be
able to load a HTML page sitting on a disk.

You can actually use that fact to discourage people from saving images from
your site. Just change the extension of all your image files to .tar.gz or
something. When they're referenced in a img tag, the browser will spiff out
the image type and display them correctly. When a user right click to save
the file, it'll end up as a .tar.gz file and won't open.

Jul 17 '05 #5

P: n/a
well what was it then?
we all might have this problem at some future time
regards
"Kevin" <bi**@village.org> wrote in message
news:d2**********@mailhub227.itcs.purdue.edu...
never mind, I have gotten the answer. thank you all.

"L?ie Techie" <laie@win_remove_get_nospam_solutions.com> дʼ
news:1111732373.9ebc38615521a8cd8e0f9fb66ebdd2a6@t eranews...
On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
> Hi all,
>
> Assuming I have stored the binary data of an image file in a blob field of > a table, how can I display it as an image in a web page? I found some
> instructions on the web, such as
>
> header('application/octet-stream');
> echo $imgdata;


First mistake - send the proper Content-type header! If it's a JPEG,
tell
the browser it's a JPEG.
>
> I don't know why I always get this warning.
>
> ----------------
> Warning: Cannot modify header information -------------
>
> How can I get rid of it and show the image as an element of the current
> web page?


That means some content was already sent. Check for any whitespace
before
your PHP code.

HTH,
La'ie Techie


Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.