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:
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.
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.
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
精彩评论