passthru() + image simple question

images php coding issues or problems here.

Moderators: macek, egami, gesf

sergio_mi
New php-forum User
New php-forum User
Posts: 23
Joined: Thu Apr 22, 2004 7:00 am

passthru() + image simple question

Postby sergio_mi » Thu Jun 17, 2004 5:10 am

Hi, I'm writing here in the image section, just because my question is basically related with image management.

Opening a page with this code:
<?
header("Content-type: image/jpeg");
passthru('http://ipAddress/images/myjpeg.jpeg');
?>
should I see myjpeg.jpeg?

I read php.net manual over this function and quoting:

A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the Content-type to image/gif and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly.

then I went to pbmplus page discovering that it can convert image type.
ok. end of the journey.

can someone send some code to output images or just a link to some documentation about that?
thanks a lot.

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Re: passthru() + image simple question

Postby swirlee » Thu Jun 17, 2004 12:42 pm

sergio_mi wrote:

Code: Select all

<?
header("Content-type: image/jpeg");
passthru('http://ipAddress/images/myjpeg.jpeg');
?>
should I see myjpeg.jpeg?


No, you sure shouldn't. passthru() executes a command (i.e. a program) on the local system. An image is not a command or a program, and a URL is not on the local system, so the above is doubly wrong.

I suggest you use fopen() and fread() or fgets(). Or, if you have PHP > 4.3, skip the middleman and use file_get_contents().


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest