I am interested in hearing about the different ways which fpassthru() can be used, and some sample code bits from any of you who have used it in the past.
One question that I have is...
If I have a html page which has an image source tag in it set to be <? getimage.php?show=dog ?>
and then getimage.php had code in similar to this...
<?
if (show == $dog)
{
$dog = "./images/dog.jpg";
fopen $dog;
fpassthru($dog);
fclose $dog;
}
would that work?
Uses of fpassthru()
Moderator: General Moderators
Uses of fpassthru()
Last edited by Benjamin on Fri May 24, 2002 7:43 am, edited 2 times in total.
Re: Uses of fpassthru()
You need to send the correct MIME type before the file contents, like thisagtlewis wrote:Code: Select all
$dog = ".images/dog.jpg"; fopen $dog; fpassthru($dog); fclose $dog;
Code: Select all
header("Content-Type: image/jpg");So it would look like this?
I didn't know you had to send a Content-Type header but it makes sense.
Code: Select all
<?
if (show == $dog)
{
header("Content-Type: image/jpg");
$dog = "./images/dog.jpg";
fopen $dog;
fpassthru($dog);
fclose $dog;
}