Re: Different images getting saved to the same file??? (ImageJPEG)
| From: | Paulo Parola | Date: | Mon, 08 Jan 2001 00:16:42 +0000 |
| Subject: | Re: Different images getting saved to the same file??? (ImageJPEG) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33144@lists.php.net to get a copy of this message | ||
Could you give me an example?
My problem is I output a lot of HTML before the image, so I imagine I have
to split my code into 2 files, one where I generate the image (lets say
stored into variable $pic), and then issue an <img src= ...> tag passing as
parameter the name of the file that actually generates the image.
Something like:
echo "<img src=\"./file_that_actually_shows_the_image.php?image=$pic\"
border=\"0\" />";
And in file "file_that_actually_shows_the_image.php" I would have something
like:
<?
Header("Content-type: image/jpg");
ImageJPEG($pic);
ImageDestroy($pic);
?>
But then I only got the following HTML output:
<img src="./file_that_actually_shows_the_image.php?image=Resource id #1"
border="0" />
Or maybe I should reference the file as:
<img
src="./file_that_actually_shows_the_image.php?barcode=2759100000004467870090
1008765010000000040001" border="0" />
and then inside "file_that_actually_shows_the_image.php" I would do all the
calculations to generate the image from the number passed as parameter and
then output the image like below:
<?
Header("Content-type: image/jpg");
...
Here I get the value of the barcode parameter, either using
HTTP_SERVER_VARS["argv"] or maybe 'urldecode';
Secondly I perform the algorithm to actually generate the image into
variable $pic
...
ImageJPEG($pic);
ImageDestroy($pic);
?>
I tried that but I also only got a broken image (the referenced PHP file did
not get interpreted):
<img
src="./file_that_actually_shows_the_image.php?barcode=2759100000004467870090
1008765010000000040001" border="0" />
What is the correct way to do that?
Thanks,
Paulo
----- Original Message -----
From: Matt Whipple <brendel@adelphia.net>
To: Paulo Parola <php@brazilinfo.com>; PHP List <php-general@lists.php.net>
Sent: Sunday, January 07, 2001 8:13 PM
Subject: Re: [PHP] Different images getting saved to the same file???
(ImageJPEG)
> If you don't have to save the files then why not just output to the
browser
> without writing a file?
> -Matt
>
> At 07:53 PM 1/7/2001 -0200, Paulo Parola wrote:
> >I am creating a barcode using function ImageJPEG as below:
> >
> > ImageJPEG($picture,"./temp/graph.jpeg");
> >
> >The image created is different according to the values informed by the
> >user in a form. A file named 'graph.jpeg' is created in directory
> >'temp'
> >and the image is shown to the user when he submits the form.
> >
> >
> >Now, how can I be sure that some user is not going to have the image
> >resulting from some other user's form submission shown at his browser if
I
> >always specify the same filename for the image created?
> >
> >==> Do I have to create different image filenames, lets say by naming the
> >image files after some combination of the user's Session ID or IP
address?
> >
> > And then (if this is the case) how should I get rid of the files
created
> > on the hard disk?
> >
> >Thanks,
> >Paulo
>
>
>