By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

header download files

P: n/a
Hi,

I have a little problem with the header function. I have a few links to pdf
files on eshop.php.
The links are like this : download.php?pdfid=1

In download.php I get the filename from the database and initiate the
download. If I click on the link, I get the internet explorer dialog box
"open, save or cancel". If I choose save, it correctly saves the file to my
hard drive. But when I choose open, Adobe acrobat says it can't find the
file. What did I do wrong, anyone an idea?

//The code in download.php, I use a static filename in stead of the database
$downfile = "test.pdf";
$rfile = $_SERVER['DOCUMENT_ROOT']."/docs/eshop/prom/".$downfile;
$filesize=filesize($rfile);
header("Cache-control: private");
header("Content-type: application/pdf");
header("Content-Length: ".$filesize);
header("Content-Disposition: attachment; filename=".$downfile);
header("Content-Transfer-Encoding: binary");
$fp = fopen($rfile, 'rb');
$pdf_buffer = fread($fp, $filesize);
fclose ($fp);
print $pdf_buffer;
exit();

//End of code

Thanks in advance!


Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 09 Apr 2004 18:39:02 +0200, surfspider wrote:
Hi,

I have a little problem with the header function. I have a few links to pdf
files on eshop.php.
The links are like this : download.php?pdfid=1

In download.php I get the filename from the database and initiate the
download. If I click on the link, I get the internet explorer dialog box
"open, save or cancel". If I choose save, it correctly saves the file to my
hard drive. But when I choose open, Adobe acrobat says it can't find the
file. What did I do wrong, anyone an idea?

There seems to be a couple of problems with IE in combination with the
Acrobat plugin.

See the FAQ of fpdf.org:
3. I try to generate a PDF and IE displays a blank page. What happens?
http://fpdf.ort/en/FAQ.php#3

They give examples of a workaround using JavaScript to redirect to the
PDF-file

Regards,
Henk Burgstra
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.