Help: problem with Headers to download PDF file
Posted on
16th Feb 2014 07:03 pm by
admin
Hi,
I'm trying to implement a script where when a user clicks a link he gets a PDF file to open or save.
In my index.php page I have the following link:
Code: <a href="http://localhost/example/get_file.php">Click here to get the file</a>
And the script is in get_file.php:
Code: <?php
$path = '/docs/document.pdf';
$mm_type="application/pdf";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: " . $mm_type);
header("Content-Length: " . filesize($path) );
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header("Content-Transfer-Encoding: binary");
readfile($path);
exit();
?>
Unfortunately it's not working properly. When clicking on the link and either selecting 'open' or 'save' from the dialog box, the end result is always the same; the end file is about 1KB in size when originally it was 456KB and therefore it's damaged.
Any ideas on why this is happening?
Thanks!
No comments posted yet
Your Answer:
Login to answer
243
28
Other forums
SAP Business Suite
Hi all:
Within the SAP Business Suite solution I would like to ask you the main differenc
Creating an invoice
Using fpdf I am trying to create an invoice to send to clients. The products are sold in pricing tie
Problem with "dynamic" index page
Hi. I have one question. In my index.php page I have this kind of code:
Code: // listaa sivut
Can I use a loop
Hi buddies!
Once again with my doubts here.
Right now I am using this sql stat
Buggy registration system
Hey, I just started scripting in PHP, and I ran into a few problems.
Code: <?php
includ
ASP.NET Validation Event Cycle
Hi,
I have asp button as follow:max() problem
I have a while loop to get image names.
Code: $imagequery = mysql_query("SELECT * FROM ad_i
Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like
Sending UDP Raw socket
I truly need help on this. I am trying to write a test program that simulate a network environment
need help in update query
hi
i have a dynamic form. i need help in how can i use update query when values from dynamic for