[nycphp-talk] Double Loading PHP as image - Firefox or PHP?
Wellington Fan
wfan at encogent.com
Wed Nov 30 20:40:01 EST 2005
Howdy,
> > > What happens if you remove the Content-Disposition header?
>
> Alright, changing the Content Disposition to 'attachment' (from inline)
> helps... When calling directly from FF 1.5 it tries to download, only
...snip...
If I understand correctly, then Chris is right, and you don't need the
Content-Disposition header, /at all/. Try commenting out the line entirely.
Yeah, you often need it, but as an inline image, you don't.
That said, I can't fathom how it should give you double hits. I just ran this
code:
<?php
$fd = fopen($_SERVER['DOCUMENT_ROOT'] . '/hitcounts.txt','a+');
fwrite( $fd, date('r') . ' | ' . $_SERVER['HTTP_USER_AGENT'] . "\n" );
header('Content-Type: image/gif');
header('Content-Disposition: inline; filename=count.gif');
readfile ($_SERVER['DOCUMENT_ROOT'] . '/images/and.gif');
?>
and it works fine; single hits every time.
BUT.....
I have a Firefox plugin that lets me peek at the response headers, and when I
turned that on -- surprise! -- it *also* requests my script, and thus,
generates another hit. Check all you plugins, especially web development-type
ones that might be generating more requests w/o your knowing it...
--
Wellington
More information about the talk
mailing list