Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is correct mimetype with Apache OpenOffice files like (*.odt, *.ods, *.odp)?

I want *.ods and *.odt files on a website to open in openoffice when clicked, not get saved on desktop, or get opened embedded in a browser etc. Now obviously it all depends on how everything is configured for each user, but what's the best MIMETYPE and other settings to achieve just that most of the time?

I know For older *.doc documents this was enough:

header("Content-Type: application/msword");

I would like solution for open office.

like image 695
Bhavin Solanki Avatar asked Jul 18 '15 09:07

Bhavin Solanki


People also ask

What file format does OpenOffice use?

OpenOffice uses ODF format as its default document format. Most other word processors, of recent vintage, also have the ability to import and export ODF.

How to Open OpenDocument format?

Open an OpenDocument Text file in Word Click the File tab. Click Open. To see only the files saved in the OpenDocument format, in the File of type list, click OpenDocument Text. Click the file you want to open, and then click Open.

What is the MIME type for pdf?

The main MIME media type for PDF is application/pdf. This type is defined by RFC 8118 and is the responsibility of ISO TC 171 SC 2 WG 8. It was last updated in March 2017, prior to the original publication of PDF 2.0, so the PDF Association is proposing a minor refresh and update in the upcoming May 2022 ISO meetings.


1 Answers

My /etc/mime.types says it's:

  • application/vnd.oasis.opendocument.text for *.odt
  • application/vnd.oasis.opendocument.spreadsheet for *.ods
  • application/vnd.oasis.opendocument.presentation for *.odp

It makes sense, as it's a corporate standard (vnd), designed by OASIS organization, used for different formats of opendocuments.

If you don't want to bother yourself about sending correct mime types, you may use finfo class to do it for you:

$finfo = new finfo(FILEINFO_MIME);
header('Content-Type: ' . $finfo->file('/path/to/file'));
like image 97
pamelus Avatar answered Oct 08 '22 16:10

pamelus