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

1

18

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.

Edgebone answered 18/7, 2015 at 9:29 Comment(1)
This solution can be use in MAC OS tooEdgebone
V
46

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'));
Venetic answered 18/7, 2015 at 10:15 Comment(1)
ODS in IIS maps to OleObject - not sure if it's safe to overwrite that but I assume so.Christalchristalle

© 2022 - 2024 — McMap. All rights reserved.