LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How do I link to odt/docx files in a webpage? (https://www.linuxquestions.org/questions/programming-9/how-do-i-link-to-odt-docx-files-in-a-webpage-506882/)

matthewhardwick 12-02-2006 01:12 PM

How do I link to odt/docx files in a webpage?
 
Hey I am trying to link to an odt (Open Document Text) file Internet Explorer always seem to want to open them in a zip program. I understand that a odt (and docx I have this problem with also) are infact ZIP files - but I want to be able to link to them in the same way I can a PDF or DOC for users to choose what doument format they want do download (PDF,DOC,DOCX,ODT).

If anyone knows of any kind of extra I can put in the tag, or some php or something I can use to make these download like normal files, and not ZIP files.

I think it is rather amusing that Firefox (and Opera) understands a DOCX is a Word file and asks to open it in Word, and yet IE programed by the same company wants to open it in WinZip!

TIA

Matt.

b0uncer 12-02-2006 01:45 PM

Well, IE isn't something behind the word "best out there".

Good though that you care about it, I know many web site creators who would just have let the problem be as it is, "it's their fault if they use such a bad browser".

I thought there was a way to "force" downloading a file rather than opening it directly but as you are wrestling with that problem, I guess not..sorry for not being able to help atm.

chadl 12-02-2006 01:45 PM

The server may be sending a MIME type that makes IE think it is a ZIP file. Try having PHP send the MIME type of application/vnd.oasis.opendocument.text or application/msword

As a hack to get around the problem, I have seen sites that say "right click and save as"... but that is not the ideal solution.

I don't use Windows, so I can not test by theory.

jschiwal 12-02-2006 01:46 PM

Add an association for that mimetype. Even better would be to not use Internet Explorer. It's even the recommendation of the dept of Homeland Security.

matthewhardwick 12-09-2006 12:32 PM

I don't use windows.... I use Firefox for most of my stuff, IE or Opera for other things... but there are of course 70% or more people that use Windows and IE so I have to look after them especially concidering I am trying to get as many people as possible to read and print and sign this document. I don't look after the server or the PHP installation as I am hosting files on a Uni web server for someone else - but I will speak to the tech guys at the Uni to get it sorted out.

This is what I thought (that PHP reads the file and see's it is a ZIP file and sends that MIME - or something to that effect).

Thanks everyone.
Matt.

chadl 12-09-2006 06:41 PM

In PHP, you can change the headers in order to tell the browser the file type:
PHP Code:

header("Content-type: text/html"); 

However, doing this requires that you read the file in PHP, and echo it out to the browser, also setting the other headers such as Content-size.

Doing this does increase the server load slightly.

It is better if the Apache configuration is updated (actually the MIME magic file on the system) to a version that can identify open document files without all this code.


All times are GMT -5. The time now is 12:33 AM.