Hi there,

I'm wanting to serve images outside the docroot of apache, so that the
images can't be so easily hijacked.  However, I appear to be running into a
problem with (I think) the headers not being sent properly.  IE (v6) will
only save the images as BMPs, not as JPGs, even though they are JPG images.
It's not the full-cache bug, as I've cleared that out while trying to solve
this problem.

Images are called like this:

<img src="/showpicture.php?pid=xxxxxx">

Where pid is the database ID of the image.

showpicture.php is basically a wrapper with some security functions to make
sure that the person is logged into my site, which then calls the following
function to display the picture.  Nothing else is output to the browser, and
the image shows just fine:

function showpix($picture_id)
        {
        $sql="SELECT ug.group_name, p.name from usenet_groups as ug,
pictures as  p WHERE p.id='$picture_id' AND ug.id=p.group_id";
        $result=mysql_query($sql) or die(mysql_error());
        $row=mysql_fetch_array($result);
        $dirhash=get_storage_dir($row["name"]);
        $picturedirectory=STORAGEDIR."/".$row["group_name"];
        $fullpicturename=$picturedirectory."/".$dirhash."/".$row["name"];
        header("Content-Type: image/jpeg");
        header("Content-Length: ".filesize($fullpicturename));
        header("Content-Disposition: inline; filename=".$row["name"]);
        readfile("$fullpicturename");
        exit;
        }

Something in here has me stumped.  Any ideas?

Bob

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to