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.
Did you know?Explore Trending and Topic pages for more stories like this.
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
Record count of entire database
Does anyone know if there is a way to obtain the number of records in each table of the database usi
curl javascript problem
Hi Experts.
I'm new curl and wanna to get some info from this http://www.amadeus.net/
when
my code does not work.
I have a code problem.
Quote"<a href=index.php?gogo=ureticidetay&'?l={$le
Display a default image
I am trying to display generic image for items that don't have one, but I can't get it to display.
IP question
ive got 2 ip addresses both global from same user how would i detect if they are local to each other
add text and number image
hi guys ..
ok see i want the user to add their name and pick a number then click get it and i
How to add an image/C++ OpenGL?
Hi,
I have been trying to look online for this and, so far, I haven't found anything usef
Probably Easy, Need help with Check Boxes in PHP Code
hello,
Thanks for looking this over and helping me out. My problem is I have a online store l
grouping within a foreach?
hello all,
I currently have a list of products spit out from my db via a foreach loop. Right
Pspell with my own dictionary
Hello!
I've tested two cases using pspell functions.
1)
Code: $dictionary_link = pspell_new