[ciapug] header problem

Matthew Nuzum newz at bearfruit.org
Thu Apr 2 10:24:42 CDT 2009


On Thu, Apr 2, 2009 at 10:03 AM, David Champion <dave at dchamp.net> wrote:
> It has other advantages... for instance you can use readfile() to access
> documents that are stored outside of the web files, if you want to
> control access to files.
>
> Could it be an issue with header() not sending the correct URL for the
> .pdf when you access the extranet? Can you use wget and see what the
> output is? If you have something checking for login creds, you may have
> to make a simple test page...
>

There's a firefox extension called "Live HTTP Headers" which can be a
big help in these situations. You just open the window and it lets you
inspect the http headers (in both directions).

I too use the readfile method in these situations. I'd try it without
the header() statement once. Naturally you're going to get a bunch of
garbage to the window but if there's a PHP error at least you'll see
what it is.

Here is the PHP I use to generate the necessary http headers. There
may be a better way now, I wrote this code years ago:

header("Content-Type: application/octet-stream");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"$name\"");
header("Content-Transfer-Encoding: binary");

The benefit of your technique using the redirect is it lets the server
deal with the headers. I don't think your way is wrong or bad. It
should work.

Maybe your filesystem is getting full or for some reason your script
can't write the output file. Turning off the header will probably
expose this.

-- 
Matthew Nuzum
newz2000 on freenode, skype, linkedin, identi.ca and twitter


More information about the ciapug mailing list