• Hello,

    I’m solving an issue with downloading a PDF file that the browser tends to open instead of downloading it. I found that it could force using the PHP header() function, but I don’t know what file to write it to? Not to wp-config.php?

    Please help

    Thank you

Viewing 1 replies (of 1 total)
  • Nowhere.

    In a previous thread you mentioned this: https://stackoverflow.com/questions/20080341/correct-php-headers-for-pdf-file-download That is not going to help you. It is for an entirely different problem.

    As you also mentioned in that thread, there is the download attribute. If you have properly added that attribute (your link should look like <a href="url/to/pdf/here.pdf" download>Download</a>) then the PDF will download instead of open directly. If your issue is that then opening the PDF opens it in the browser, then there’s nothing you can do about that. That’s browser behaviour, particularly in Chrome.

    There might be a Chrome setting that lets you change this behaviour, but that’s not something you can force for other users.

Viewing 1 replies (of 1 total)

The topic ‘In which file should I write the php header() function?’ is closed to new replies.