PDF Download / View
| From: | Ville Mattila | Date: | Thu, 18 Oct 2001 11:54:15 +0000 |
| Subject: | PDF Download / View | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-71471@lists.php.net to get a copy of this message | ||
Hello world,
I've made a little script which simply returns a pdf file through it (script file called dl.php
in the chart-directory):
<?
$file_size = filesize($filepath);
Header("Content-Type: application/pdf");
Header("Content-Length: ".$file_size);
readfile($filepath);
?>
This script works fine when there is Acrobat Reader Browser -plug-in installed to users' box so
that the PDF File appears into the IE's or Netscapes' normal window. But if and when user
wants to save the pdf file (which should be allowed), some problem appear. In the case that user
right-clicks the link to this script and selects "Save the file as..." (or something, I
have Finnish version of IE ;) the browser thinks that user is downloading chart.html -file! I
suppose that same "phenomenon" appears when there is no Acrobat plug-in installed and
browser doesn't find corresponding action for application/pdf -mime type -> it begins to
download file.
Any suggestions how user can download the file via that script as the file will be saved as
pdf-file?
Thanks and cheers,
- Ville
.................................................................
Ville Mattila
Ikaalinen, Finland
gsm +358-40-8497506
ville.mattila@pilotmedia.fi
www.pilotmedia.fi