|
Posted by kenoli on 12/24/06 18:13
Actually, it did work. I was trying to retrieve a record that was
empty for some reason. When I treid a different record, I got the
image.
I am flying a bit here on blind faith, as I don't quite understand what
is happening with the header() function. I surmise from what I've read
that the header function says something like "On this page we will be
outputting a png file." Then the browser (I presume it is the browser
as what we are working with here is an http header) interprets the data
sent via the echo statement as a png file.
Then, when we refer to the view.php script from the <img> tag, what is
returned is the output of the echo statement in the view.php script
interpreted as an image.
Is this something like accurate?
It is interesting to me that if I run the view.php script in a browser
without including it in an <img> tag, nothing is sent to the browser.
I don't even see the header information in the source code for that
page. I think I still don't fully understand what is going on with
these headers. It may be something I don't understand about http.
I hate taking things on faith without fullyunderstanding them. There
are a lot of baroque logical turns in all of this, at least in my way
of thinking about it.
Anyway . . .
Thanks,
--Kenoli
J.O. Aho wrote:
> kenoli wrote:
> > I want to store thumbnail images in a table with person data and then
> > retreive the image data and dislay it on a web page along with other
> > data about the person. All of the examples showing how to retrieve
> > image data from a blob field seem to assume that it will be displayed
> > on a separate page sending a header like this:
> >
> > Header( "Content-type: $type");
> > echo $data;
>
> To make it easy, we assume this script (what you call page) is called view.php
>
>
> > I'd like to retrieve the data and display it on a page in the middle of
> > other information like I would an image file stored in a directory,
> > e.g.
> >
> > <img src=[data from the blob field]>
>
> With the previous assumption
> <img src="view.php?id=<?php echo $imageid; ?>" title="my dynamig image"
> alt="missing image">
>
>
> > I don't really understand the Header . . . echo construction. I have
> > just seen examples of this but no explanations about is how this works.
>
> header is used to describe the contents of the data that is sent and is
> specially useful when you send image data instead of html.
>
> http://www.php.net/manual/en/function.header.php
>
>
>
> > I thought about perhaps retrieving the data from the blob and then
> > writing it to a file and then displaying the file using <img> but
> > couldn't figure out how to do that aside from thinking it may use
> > file_put_contents() somehow, though I couldn't figure out exactly how
> > to do it.
>
> Thats possible to do, specially on a low traffic site, but with increasing
> traffic you will just get high slowdowns and even risk of wrong images displayed.
>
>
> --
>
> //Aho
Navigation:
[Reply to this message]
|