View Single Post
Old Mar 16th, 2007, 3:32 PM   #7
woozy
Newbie
 
Join Date: Mar 2007
Posts: 15
Rep Power: 0 woozy is on a distinguished road
Quote:
Originally Posted by Styx View Post
In reference to my example, why don't you put your page within the else {} block? In the script, they are acting as two, completely different pages, not like one page within another. That's why both are separated in the first place: the image content has to be all by itself with just its headers to care for it =P
I guess I don't understand what you are saying. And as we are discussing it an three (at least) levels of coding we are having a hard time communicating.

Level0)At the browser level what I want the user to see is web page that looks something like this:
:::::::::::::::::
HI THERE

:::::::::::::::::
Level1)At the HTML code level that be something like:
<h1>HI THERE</h1>
<img src="http://www.sirentiger.com/fatherbear.jpg">
*except* I don't actually have the a file for the img source, of course.

Now, the page itself (lets call the page itself "page.php") is a http request/response and the <img> is a second http request/response which I say is "within" the page although that could be rather lazy semantics.

(Quite probably, I am badly abusing technical and precise terminology do to a less than thourough understanding http-request/response mechanics. If so, I apologize and I hope to be enlightened.)

Level2) at PHP code I want to one of two things (although maybe neither of these things are possible).

Either I want to write a a second sepearate PHP script (Let's call the second script "image.php") which renders the image:
a--
page.php:::

$image = fread(...get the image content...);
$type = "image/jpeg";

echo "<h1>HI THERE<h1>\n";
echo "<img src='image.php>";

...plus some code to get $image and $type to image.php....
==========
image.php:::

... some code to get $image and $type from page.php...

header("Content-type: $type");
echo($image);
or I was to somehow "inject" my image into page.php:
page.php
header("Content-type: text/html");
echo("<h1>HI THERE</h1>");

$image = fread(.......);
$type = "image/jpeg";

header("Content-type: $type");
echo($image);
*won't* work because the header("Content-type: $type"); line redirects to a new page of just the image.
page.php
header("Content-type: text/html");
echo("<h1>HI THERE</h1>");

$image = fread(.......);
$type = "image/jpeg";

//header("Content-type: $type");
echo($image);
won't work because $image will be spelled out as a long string. What I need is something like:
page.php
header("Content-type: text/html");
echo("<h1>HI THERE</h1>");

$image = fread(.......);
$type = "image/jpeg";

header_but_not_a_redirect_keep_original_request_open("Content-type: $type");
echo($image);
close_the_second_request_but_still_keep_first_open();
Hmmm, I think I've seen something like that done before.
woozy is offline   Reply With Quote