I have a website that’s not ready for production yet, but my client has a pdf file that he wants to make available for download for his visitors upon entering the website. Meaning that some fo his customers will enter the site explicitly to download this file. How can I redirect them so that when trying to enter the site they’re prompt with the ‘do you want to open/save this pdf file’ window?
I’m thinking a ‘htaccess’ file would help but not sure what would be the instruction, or if there’s another way.
EDIT 1:
@webarto. I’m not sure how to do that. I found the following code on the php.net manual but couldn’t make it work:
<?php
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="file.pdf"');
readfile('path/to/file.pdf');
?>
Is this the right code for this? how can I correct it?
EDIT 2:
Actually the above code did work, I had the wrong path to the pdf file so that fixed it.
Thanks to webarto I searched and found the solution; I just placed the following code before the doctype declaration of index.php:
Thanks a lot for your suggestions 🙂