Page 1 of 1

Making a script produce an image output

Posted: Sat Oct 11, 2003 5:24 pm
by Stoneguard
Ok, I know I have seen this recently, adn cannot for the life of me find it. I have working script which basically returns an image as the result of the page request. The problem I am having is it is also opening a second browser window when as well as displaying the image properly in the first window.

Here is the code I have. What am I missing?

Test.php

Code: Select all

<?php
header("Content-type: image/jpeg");

$file = "C:\\...\\image.jpg";

readfile($file);
?>
Calling html

Code: Select all

&lt;img src="test.php"&gt;

Posted: Sat Oct 11, 2003 5:25 pm
by JAM
I'd use...

Code: Select all

header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("Pragma: no-cache");
header("Content-Type: image/jpeg"); 
$file = "C:\\...\\image.jpg";
readfile($file);
Never had the issue with another browser window opening tho...

Posted: Sat Oct 11, 2003 6:03 pm
by Stoneguard
For some reason, it still occurs, even when calling it from another server.

Posted: Sat Oct 11, 2003 6:47 pm
by Gen-ik
I use a similar thing.... <img src="image.php?makethumb=image.jpg"> but haven't had any trouble with extra windows opening either.

Which browser are you using?

Posted: Sat Oct 11, 2003 6:56 pm
by Stoneguard
I am doing my development for IE 5.5 or later because of my customer base. I actually use IE 6.0. It may be something simple with my test page, I will work more on it tomorrow.

Posted: Sun Oct 12, 2003 9:18 am
by Nay
Go to my avatar:

http://www.chaosdreamers.com/external/s ... .php/1.jpg

Do you get a <img src="wateverimage.jpg" /> or an image in the browser window with a source that is not viewable?

Maybe that's a start, since something could be missing.

-Nay

Posted: Sun Oct 12, 2003 1:22 pm
by m3rajk
umm... stonegaurd: pm me on this with an im service and name (eg: aim:stonegaurd ) if you're still having issues. i have something that works in 6.0 and does a bunch of stuff with images, i jsut wanna talk realtime and make sure that what i have is close enough to what your doing to be applicable. if so i'll give you the script and you can go from there to figure out what's going wrong

Posted: Sun Oct 12, 2003 6:44 pm
by Stoneguard
Nay, what you gave me is strictly an image with no source. This gave me the idea to test my image and make sure the test file returns the same, and it does. there is no viewable source with the image being returned from test.php. Thanks for the idea though, was definitely worth a thought!

m3, I sent you a PM. I am in the Eastern US, so you will most likely catch me during the daylight / evening hours here. :).

Posted: Mon Oct 13, 2003 11:51 am
by Stoneguard
Heh, I finally figured out my problem. User error :oops: . The page I was testing it with had an explicit window.open() in javascript way down near the bottom. Thanks for all the help!