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.
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.
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.
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.
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'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With