IE doesn't load PDF sometimes and prints garbage
I have Apache running on RedHat Linux and have a site that redirect user to different PDF files. However, I SOMETIMES got the PDF file printed on IE instead of loading Acrobat Reader. I am using IE 6 and Acrobat Reader 6. I have been looking for a solution but failed. This is urgent! Please help.
My file:
--------
<?php
$link=$_REQUEST["link"];
$ext = strtolower(stristr($link, '.'));
if (strcmp($ext, '.pdf')==0) {
// We'll be outputting a PDF
header("Content-type: application/pdf");
// The PDF source is in original.pdf
readfile($link);
} else {
echo "<html><head><META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=$link;\"></BODY></HTML>";
}
?>
Garbage that I got from IE
---------------------------------
R /im555 1770 0 R /im556 1772 0 R /im557 1774 0 R /im558 1776 0 R /im559 1778 0 R /im560 1780 0 R /im561 1782 0 R /im562 1784 0 R /im563 1786 0 R /im564 1788 0 R /im565 1790 0 R /im566 1792 0 R /im567 1794 0 R /im568 1796 0 R /im569 1798 0 R --3f5009ae6df7-- HTTP/1.1 206 Partial Content Date: Sat, 30 Aug 2003 02:19:27 GMT Server: Apache/1.3.14 (Unix) (Red-Hat/Linux) mod_jk DAV/1.0.1 PHP/4.2.1 Last-Modified: Fri, 31 May 2002 04:06:26 GMT ETag: "1060e0-24c216-3cf6f6c2" Accept-Ranges: bytes Content-Length: 1567541 Content-Range: bytes 841441-2408981/2408982 Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Content-Type: application/pdf ÇM0? r ¸r8h4?xl;?ºk P4? ?áA ?f* ? a(?a??qL ?l+k_?‡b?æVëE[#??2??eÁÈÀÞí¦?h5ÞÖÖû?0˜L' !aÌzh4??@??.ši_Âe??ÎèXD,(a ˜è0?g!0Gde9RP?ÀÆC?B"?íÕºë??Ûé…¡?µ >Þ¾?ÿ endstream endobj 1428 0 obj 41 endobj 1429 0 obj << /Type /XObject /Subtype /Image /Name /im496 /Filter /CCITTFaxDecode /Width 5102 /Height 51 /BitsPerComponent 1 /ColorSpace /DeviceGray /Length 1428 0 R /DecodeParms << /K -1 /Columns 5102 >> >> stream
................... (many more)
|