stuff i've added to my header class

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "
GMT");
                header("Cache-Control: no-store, no-cache, must-
revalidate");
                header("Cache-Control: post-check=0, pre-check=0", false);
                header("Pragma: no-cache");

header("Content-Type: $this->_application_type");


to download

header("Content-Disposition: attachment; filename=".basename($this-
>_filename).";");
                         header("Content-Transfer-Encoding: binary");
                         header("Content-Length: ".filesize($this-
>_filename));
                         readfile("$this->_filename");



to output

readfile("$this->_filename");
>
> I have been using a php file to stream pdf (and various other sorts of
> files)... Here's my code.
>
> <?php
>            if         ($extension == ".doc"){$type =
>            "application/msword";} else if ($extension == ".pdf"){$type
>            = "application/pdf";} else if ($extension == ".exe"){$type =
>
> "application/octet-stream";}
>            else if ($extension == ".ppt"){$type =
> "application/vnd.ms-powerpoint";}
>            else if ($extension == ".xls"){$type =
> "application/vnd.ms-excel";}
>            else if ($extension == ".xml"){$type = "text/xml";}
>            else if ($extension == ".zip"){$type = "application/zip";}
>            else if ($extension == ".txt"){$type = "text/plain";}
>            else {
>                $type="application/octet-stream";
>            }
>
>
>            header("Content-type: " . $type);
>            header("Accept-Ranges: bytes");
>            header("Content-Length: ".filesize($file));
>            readfile($file);
> ?>
>
> And so this worked perfectly well when I did something like this:
> loadfile.php?file=name.pdf (where name.pdf is the file I am loading and
>  loadfile.php is the name of the script).  But
> loadfile.php?file=directory/name.pdf (when launching Adobe acrobat)
> would give me the error 'File Does not begin with '%PDF' ".
>
> I was able to add this header line:
>
>    header("Content-Disposition: attachment;
> filename=".basename($file).";");
>
> which forced the user to be prompted if he wanted acrobat to be loaded
> or to save the file.  Both options worked flawlessly.
>
> So why did it not work before I added this header line?  Is it a flaw
> in  Adobe Acrobat?
>
> Best Regards,
>
> Scott Taylor
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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

Reply via email to