Re: using header() to server tiff
| From: | Ernest E Vogelsinger | Date: | Thu, 08 May 2003 10:19:30 +0000 |
| Subject: | Re: using header() to server tiff | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146815@lists.php.net to get a copy of this message | ||
At 11:57 08.05.2003, hboyce@eab.co.uk said:
--------------------[snip]--------------------
>I'm trying to write an image server script to serve tif/tiff files so that
>they will open in a browser using an appropriate plug-in. If I just do
>an href to the file they open fine, however for security reasons we
>want to keep the files outside the document root. The result is a
>screen of binary displayed in ascii characters. The code I am using
>is:
>
><?php
> $file = "test.tif";
> header("Cache-control: private");
> header ("Content-Type: image/tiff");
> header("Content-Length: ".filesize($file));
> header ("Content-transfer-encoding: binary");
> header ("Content-Disposition: inline; filename = \"$file\"");
> $fp = fopen($file, 'rb');
> fpassthru($fp);
>
>Has anyone had to do this before? Any help gratefully appreciated.
--------------------[snip]--------------------
This should work as expected, as far as I can see.
I suspect that some data has already been sent before your binary file,
maybe some space after a closing ?> tag, so PHP transmits the default
text/html content header.
If you're on X, you can inspect the effective server output with lynx:
lynx --mime_header http://myhost/myscript?somemore |
less
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/