On Thu, 17 Mar 2005 00:02:16 +0100, an orbiting mind-control laser
made "Alvaro G. Vicario" <kA*****************@terra.es> write:
*** bh*****@gmail.com escribió/wrote (16 Mar 2005 13:33:26 -0800): http://www.2006ymcanationals.com/random.php
IT WORKS IF I go directly to the above link.
I am trying to call that in another page so that i get a random image
the page is http://2006ymcanationals.com/index.php using <img
src="random.php">
Your script does not return an image. It returns an HTML page that links to
an image. You cannot link to an HTML page with the <img> tag. Maybe you're
thinking of <iframe>?
You could either choose a random filename:
<img src="<?=get_random_img_name()?>">
Or make your script return an actual image:
<?
header('Content-Type: image/gif');
readfile('foo.gif');
?>
You know... I'm experiencing a very similar issue.
In my case, I am building a counter script (* non-relevant reasons
below) and I have similar behavior. I call the script directly in its
own directory and it outputs the composite image fine. Calling it
from one directory higher from within an HTML file gives a broken
image.
Originally, I copied from another script that output multiple
individual gifs when the script was called. I never understood how
that was supposed to work, other than as a stand-alone script, so I
redid the code to copy each image jpg into one image that I output
from the script.
Relevant code:
<<<
//determine size of images in directory by testing the zero image
$source = $style_folder . "0." . $ext;
$img_size = @getimagesize( $source );
// $width is string length in characters
$dst_img=ImageCreate( $width * $img_size[0], $img_size[1] );
for ($i=0;$i<strlen($countstring);$i++) {
$digit=substr("$countstring",$i,1);
// Build the image URL ...
$source = $style_folder . $digit . "." . $ext;
$src_img = imagecreatefromjpeg( $source );
// $source = $base_url . $style_folder . $digit . "." . $ext;
// echo "<img src=\"$source\" border=0>";
imagecopy( $dst_img, $src_img, $i * $img_size[0], 0, 0, 0,
$img_size[0], $img_size[1]);
}
header( "Content-type: image/jpeg" );
ImageJpeg($dst_img);
exit();
<<<
And from the calling HTML:
<<<
<img src="_Counters/jpbcount.php?link=Tester&style=odometer"
height="20" align="ABSMIDDLE">
<<<
I've tried calling the script with both an <img src= and <img
href= to no avail.
Any pointers?
Thanks.
-JPB
*Non-relevant rationale
I may be migrating my server over to a Linux-based hosting service
from my own Windows 2000-based server. I liberally used a CGI program
on my site and now that I may be going to a Linux-based system, I
figured I'd mimic the functionality of it in a more portable PHP
script.