WooCaSh
WooCaSh

Reputation: 5212

Problem with opening pdf file in site

I have pdf file in serwer and link to it. In local host when i click on link pdf file display in site. On server I've got popup with asking to download file. How to change type from application/octet-stream to application/pdf to display pdf normal on site? Here is screen after clicking on link:

enter image description here

Upvotes: 1

Views: 10992

Answers (3)

rightstuff
rightstuff

Reputation: 6522

The reason that the listed solutions are reported not to work half the time, is because using the default MIME association or setting the Content-Type header in <Files> or <FilesMatch> (for the PDF file extension) will have no effect on PDF files that are dynamically transferred via PHP code (i.e., readfile())...

To force a PDF to open in the browser rather than downloading, you should use LocationMatch instead:

<LocationMatch "\.(?i:pdf)$">
    ForceType application/pdf
    Header set Content-Disposition inline
</LocationMatch>

This way it picks up on transfers that are not direct from the file-system.

Upvotes: 2

WooCaSh
WooCaSh

Reputation: 5212

Problem solved with using solution from this site:
http://www.thingy-ma-jig.co.uk/blog/06-08-2007/force-a-pdf-to-download

Thanks Joost Evertse

Upvotes: 0

Joost Evertse
Joost Evertse

Reputation: 1075

If it a unix server add an entry for pdfs in /etc/mime.types, if it's a Windows server, add a mime type in IIS.

Upvotes: 1

Related Questions