How to install Content-type in Joomla?

I am developing a Joomla component, and one of the views should display itself as a PDF. In the view, I tried to set the content type with the following line, but when I see the answer, it is text / html anyway.

header('Content-type: application/pdf'); 

If I do this on a regular php page, everything works as expected. It seems I need to tell Joomla to use the / pdf application instead of text / html. How can i do this?

Note. Setting other headers, such as Content-Disposition , works as expected.

+6
content-type php joomla
source share
3 answers

Since version 1.5, Joomla has a JDocument object. Use JDocument :: setMimeEncoding () to set the content type.

 $doc =& JFactory::getDocument(); $doc->setMimeEncoding('application/pdf'); 

In your special case, you can see JDocumentPDF .

+12
source share

For those of you who think the above is a very old answer, I confirm that JDocument :: setMimeEncoding () still works even in version 1.6 (I haven't tried it on 1.7 yet).

+1
source share

I had the same problem in joomla 2.5. After 8 hours of clicking on the joomla admin panel, I found a solution.

  • Log in to the joomla admin panel and click on the media manager
  • Click the options button in the upper right corner. This opens the configuration tab with various options.
  • In the field for legal file extensions, application / pdf or whatever you need. Values ​​are separated by a comma. Notice, apparently, you should list things in alphabetical order according to the forum I just found.
  • Click save button

Now you can upload pdf files to the media manager. Hope this works for you. I just installed that I downloaded the .mov extensions.

The problem is that it only works once. Now the link to view does not work when I go to the movie .mov file on my hard drive. But does it do if I select any other type of file?

0
source share

All Articles