Skip to content
Advertisement

correct PHP headers for pdf file download

I’m really struggling to get my application to open a pdf when the user clicks on a link.

So far the anchor tag redirects to a page which sends headers that are:

JavaScript

this doesn’t seem to work, has anybody successfully sorted this problem in the past?

Advertisement

Answer

Example 2 on w3schools shows what you are trying to achieve.

JavaScript

Also remember that,

It is important to notice that header() must be called before any actual output is sent (In PHP 4 and later, you can use output buffering to solve this problem)

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement