0

I need to create a link for downloading a pdf file .

But sometimes the pdf file will open in the browser and sometimes it will get downloaded.

How can I make sure that the pdf file is always downloaded.

user1216750
  • 483
  • 3
  • 10
  • 17

1 Answers1

0

As this question is a duplicate, I'll just answer to make the answer more clear. Create a php page like this:

myFile.pdf.php

<?php
    header('Content-Disposition: attachment; filename="path/to/your/file.pdf"');
?>

and if you call this page (e.g. http://domain.com/myFile.pdf) it will download the pdf file. Make sure this page and the actual file don't have the same exact name and location!

blex
  • 24,941
  • 5
  • 39
  • 72