Connecting Tech Pros Worldwide Help | Site Map

how to display the data of an image file

  #1  
Old July 17th, 2005, 01:17 PM
Kevin
Guest
 
Posts: 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





  #2  
Old July 17th, 2005, 01:17 PM
Lāʻie Techie
Guest
 
Posts: n/a

re: how to display the data of an image file


On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
[color=blue]
> 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;[/color]

First mistake - send the proper Content-type header! If it's a JPEG, tell
the browser it's a JPEG.
[color=blue]
>
> 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?[/color]

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

HTH,
La'ie Techie

  #3  
Old July 17th, 2005, 01:17 PM
Monte Watson
Guest
 
Posts: n/a

re: how to display the data of an image file


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:[color=blue]
> 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
>
>
>
>
>[/color]
  #4  
Old July 17th, 2005, 01:17 PM
Kevin
Guest
 
Posts: n/a

re: how to display the data of an image file


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...[color=blue]
> On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
>[color=green]
> > Hi all,
> >
> > Assuming I have stored the binary data of an image file in a blob field[/color][/color]
of[color=blue][color=green]
> > 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;[/color]
>
> First mistake - send the proper Content-type header! If it's a JPEG, tell
> the browser it's a JPEG.
>[color=green]
> >
> > 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?[/color]
>
> That means some content was already sent. Check for any whitespace before
> your PHP code.
>
> HTH,
> La'ie Techie
>[/color]


  #5  
Old July 17th, 2005, 01:17 PM
Chung Leong
Guest
 
Posts: n/a

re: how to display the data of an image file



"La?ie Techie" <laie@win_remove_get_nospam_solutions.com> wrote in message
news:1111732373.9ebc38615521a8cd8e0f9fb66ebdd2a6@t eranews...[color=blue]
> On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
>[color=green]
> > Hi all,
> >
> > Assuming I have stored the binary data of an image file in a blob field[/color][/color]
of[color=blue][color=green]
> > 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;[/color]
>
> First mistake - send the proper Content-type header! If it's a JPEG, tell
> the browser it's a JPEG.[/color]

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.



  #6  
Old July 17th, 2005, 01:18 PM
iz0nlee
Guest
 
Posts: n/a

re: how to display the data of an image file


well what was it then?
we all might have this problem at some future time
regards
"Kevin" <bird@village.org> wrote in message
news:d20d04$bjl$1@mailhub227.itcs.purdue.edu...[color=blue]
> 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...[color=green]
>> On Fri, 25 Mar 2005 01:00:55 -0500, Kevin wrote:
>>[color=darkred]
>> > Hi all,
>> >
>> > Assuming I have stored the binary data of an image file in a blob field[/color][/color]
> of[color=green][color=darkred]
>> > 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;[/color]
>>
>> First mistake - send the proper Content-type header! If it's a JPEG,
>> tell
>> the browser it's a JPEG.
>>[color=darkred]
>> >
>> > 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?[/color]
>>
>> That means some content was already sent. Check for any whitespace
>> before
>> your PHP code.
>>
>> HTH,
>> La'ie Techie
>>[/color]
>
>[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to Display Image from database at runtime den 2005 answers 3 August 3rd, 2006 01:35 AM
Displaying image after selecting an image file. http://www.visual-basic-data-mining.net/forum answers 1 November 18th, 2005 07:02 PM
How to open an image file and display in picturebox? Bradley1234 answers 2 November 16th, 2005 03:58 PM
Selecting part of an image and storing it in an ODBC data source Al Findlay answers 3 July 17th, 2005 09:49 AM